ManishThota commited on
Commit
a333293
1 Parent(s): 85e7ead

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -14
app.py CHANGED
@@ -126,17 +126,35 @@ def gradio_predict(image, video, question, max_tokens):
126
  answer = predict_answer(image, video, question, max_tokens)
127
  return answer
128
 
129
- iface = gr.Interface(
130
- fn=gradio_predict,
131
- inputs=[
132
- gr.Image(type="pil", label="Upload or Drag an Image"),
133
- gr.Video(label="Upload your video here"),
134
- gr.Textbox(label="Question", placeholder="e.g. Can you explain the slide?", scale=4),
135
- gr.Slider(2, 500, value=25, label="Token Count", info="Choose between 2 and 500")],
136
- outputs=gr.TextArea(label="Answer"),
137
- # outputs=gr.Image(label="Output"),
138
- title="Video/Image Viewer",
139
- description="Upload an image or video to view it or extract frames from the video.",
140
- )
141
-
142
- iface.launch(debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  answer = predict_answer(image, video, question, max_tokens)
127
  return answer
128
 
129
+ # iface = gr.Interface(
130
+ # fn=gradio_predict,
131
+ # inputs=[
132
+ # gr.Image(type="pil", label="Upload or Drag an Image"),
133
+ # gr.Video(label="Upload your video here"),
134
+ # gr.Textbox(label="Question", placeholder="e.g. Can you explain the slide?", scale=4),
135
+ # gr.Slider(2, 500, value=25, label="Token Count", info="Choose between 2 and 500")],
136
+ # outputs=gr.TextArea(label="Answer"),
137
+ # # outputs=gr.Image(label="Output"),
138
+ # title="Video/Image Viewer",
139
+ # description="Upload an image or video to view it or extract frames from the video.",
140
+ # )
141
+
142
+ # iface.launch(debug=True)
143
+
144
+
145
+ with gr.Blocks() as app:
146
+ gr.Markdown("### Upload an Image or Video")
147
+ with gr.Row():
148
+ image = gr.Image(type="pil", label="Upload or Drag an Image")
149
+ video = gr.Video(label="Upload your video here")
150
+ with gr.Row():
151
+ with gr.Column():
152
+ question = gr.Textbox(label="Question", placeholder="e.g. Can you explain the slide?", lines=4)
153
+ tokens = gr.Slider(2, 500, value=25, label="Token Count", info="Choose between 2 and 500")
154
+ with gr.Column():
155
+ answer = gr.TextArea(label="Answer")
156
+
157
+ btn = gr.Button("Predict")
158
+ btn.click(gradio_predict, inputs=[image, video, question, tokens], outputs=answer)
159
+
160
+ app.launch(debug=True)