paloma99 commited on
Commit
e120d49
1 Parent(s): f8c157e

Hotdog + Chatbot

Browse files
Files changed (1) hide show
  1. app.py +24 -9
app.py CHANGED
@@ -1,18 +1,33 @@
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(input_img):
7
- predictions = pipeline(input_img)
8
- return input_img, {p["label"]: p["score"] for p in predictions}
9
 
 
 
 
 
 
 
 
 
 
 
10
  gradio_app = gr.Interface(
11
- predict,
12
- inputs=gr.Image(label="Select hot dog candidate", sources=['upload', 'webcam'], type="pil"),
13
- outputs=[gr.Label(label="Result", num_top_classes=1)],
14
- title="Hot Dog? Or Not?",
 
 
 
 
 
 
 
15
  )
16
 
17
- if __name__ == "__main__":
18
  gradio_app.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ pipeline_hotdog = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
5
 
6
+ chatbot_pipeline = pipeline(task="text-generation", model="microsoft/DialoGPT-medium")
 
 
7
 
8
+ def predict(input_img,chat_input):
9
+ hotdog_predictions = pipeline_hotdog(input_img)
10
+ # Generate chatbot response
11
+ chatbot_response = chatbot_pipeline(chat_input, max_length=50)[0]['generated_text']
12
+
13
+ return input_img, {
14
+ "Hotdog Classification": {p["label"]: p["score"] for p in hotdog_predictions},
15
+ "Chatbot Response": chatbot_response
16
+ }
17
+
18
  gradio_app = gr.Interface(
19
+ fn=predict,
20
+ inputs=[
21
+ gr.Image(label="Select hot dog candidate", sources=['upload', 'webcam'], type="pil"),
22
+ gr.Textbox(label="Chatbot Input", placeholder="Type something to chat with the bot")
23
+ ],
24
+ outputs=[
25
+ gr.Image(label="Processed Image"),
26
+ gr.Label(label="Hotdog Classification", num_top_classes=2),
27
+ gr.Textbox(label="Chatbot Response", output_transform=lambda x: x["Chatbot Response"], type="readonly")
28
+ ],
29
+ title="Hot Dog? Or Not? with Chatbot",
30
  )
31
 
32
+ if _name_ == "_main_":
33
  gradio_app.launch()