Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,46 +1,15 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import openai
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
openai.api_key = "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"
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|