RamV commited on
Commit
54ecb0b
·
1 Parent(s): 065fd56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -42
app.py CHANGED
@@ -1,46 +1,15 @@
1
- import os
2
- import openai
3
  import gradio as gr
 
4
 
5
- # Set the OpenAI API key as an environment variable
6
- openai.api_key = "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"
7
 
8
- start_sequence = "\nAI:"
9
- restart_sequence = "\nHuman: "
 
10
 
11
- # Define the conversation prompt
12
- conversation_prompt = "Welcome to ChatRobo, kindly type in your enquiries: "
13
-
14
- # Define the function to generate a response from the GPT model
15
- def openai_chat_history(input, history):
16
- history = history or []
17
- if input.strip() != "":
18
- s = list(sum(history, ()))
19
- s.append(input)
20
- inp = ' '.join(s)
21
- output = openai_create(inp)
22
- history.append((input, output))
23
- return history[-1][1]
24
- else:
25
- return ""
26
-
27
- def openai_create(prompt):
28
- response = openai.Completion.create(
29
- model="text-davinci-003",
30
- prompt=prompt,
31
- temperature=0.9,
32
- max_tokens=150,
33
- top_p=1,
34
- frequency_penalty=0,
35
- presence_penalty=0.6,
36
- stop=["Human:", "AI:"]
37
- )
38
-
39
- return response.choices[0].text
40
-
41
- block = gr.Interface(
42
- fn=openai_chat_history,
43
- inputs=[gr.inputs.Textbox(placeholder=conversation_prompt)],
44
- outputs=[gr.outputs.Textbox(label="ChatRobo Output")]
45
- )
46
- block.launch()
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
 
5
 
6
+ def predict(image):
7
+ predictions = pipeline(image)
8
+ return {p["label"]: p["score"] for p in predictions}
9
 
10
+ gr.Interface(
11
+ predict,
12
+ inputs=gr.inputs.Image(label="Upload hot dog candidate", type="filepath"),
13
+ outputs=gr.outputs.Label(num_top_classes=2),
14
+ title="Hot Dog? Or Not?",
15
+ ).launch()