Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
3 |
import torch
|
4 |
|
5 |
-
# Image Classification Model
|
6 |
image_pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
7 |
|
8 |
def predict_image(input_img):
|
@@ -16,7 +16,7 @@ image_gradio_app = gr.Interface(
|
|
16 |
title="Hot Dog? Or Not?",
|
17 |
)
|
18 |
|
19 |
-
# Chatbot Model
|
20 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
|
21 |
chatbot_model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-medium")
|
22 |
|
@@ -29,17 +29,17 @@ def predict_chatbot(input, history=[]):
|
|
29 |
response_tuples = [(response[i], response[i+1]) for i in range(0, len(response)-1, 2)]
|
30 |
return response_tuples, history
|
31 |
|
32 |
-
chatbot_gradio_app = gr.
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
2 |
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
3 |
import torch
|
4 |
|
5 |
+
# Cell 1: Image Classification Model
|
6 |
image_pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
7 |
|
8 |
def predict_image(input_img):
|
|
|
16 |
title="Hot Dog? Or Not?",
|
17 |
)
|
18 |
|
19 |
+
# Cell 2: Chatbot Model
|
20 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
|
21 |
chatbot_model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-medium")
|
22 |
|
|
|
29 |
response_tuples = [(response[i], response[i+1]) for i in range(0, len(response)-1, 2)]
|
30 |
return response_tuples, history
|
31 |
|
32 |
+
chatbot_gradio_app = gr.Interface(
|
33 |
+
fn=predict_chatbot,
|
34 |
+
inputs=gr.Textbox(show_label=False, placeholder="Enter text and press enter"),
|
35 |
+
outputs=gr.Textbox(),
|
36 |
+
live=True,
|
37 |
+
title="Chatbot",
|
38 |
+
)
|
39 |
+
|
40 |
+
|
41 |
+
# Combine both interfaces into a single app
|
42 |
+
gr.TabbedInterface(
|
43 |
+
[image_gradio_app, chatbot_gradio_app],
|
44 |
+
tab_names=["image","chatbot"]
|
45 |
+
).launch()
|