Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -47,23 +47,23 @@ def llm_response(history,text,img):
|
|
47 |
|
48 |
# Function that takes User Inputs and displays it on ChatUI
|
49 |
text_box_01 = "what is in the image"
|
50 |
-
def output_query_message(
|
51 |
if not img:
|
52 |
-
return
|
53 |
base64 = image_to_base64(img)
|
54 |
data_url = f"data:image/jpeg;base64,{base64}"
|
55 |
-
outputText = [(f"{
|
56 |
return outputText
|
57 |
|
58 |
# Function that takes User Inputs, generates Response and displays on Chat UI
|
59 |
-
def output_llm_response(
|
60 |
if not img:
|
61 |
-
response = txt_model.generate_content(
|
62 |
return response.text
|
63 |
|
64 |
else:
|
65 |
img = PIL.Image.open(img)
|
66 |
-
response = vis_model.generate_content([
|
67 |
return response.text
|
68 |
|
69 |
|
@@ -82,10 +82,10 @@ with gr.Blocks(theme='snehilsanyal/scikit-learn') as app1:
|
|
82 |
|
83 |
btn = gr.Button("Check This")
|
84 |
clicked = btn.click(output_query_message,
|
85 |
-
[
|
86 |
outputbox
|
87 |
).then(output_llm_response,
|
88 |
-
[
|
89 |
outputbox
|
90 |
)
|
91 |
gr.Markdown("""
|
|
|
47 |
|
48 |
# Function that takes User Inputs and displays it on ChatUI
|
49 |
text_box_01 = "what is in the image"
|
50 |
+
def output_query_message(img):
|
51 |
if not img:
|
52 |
+
return text_box_01
|
53 |
base64 = image_to_base64(img)
|
54 |
data_url = f"data:image/jpeg;base64,{base64}"
|
55 |
+
outputText = [(f"{text_box_01} ![]({data_url})", None)]
|
56 |
return outputText
|
57 |
|
58 |
# Function that takes User Inputs, generates Response and displays on Chat UI
|
59 |
+
def output_llm_response(img):
|
60 |
if not img:
|
61 |
+
response = txt_model.generate_content(text_box_01)
|
62 |
return response.text
|
63 |
|
64 |
else:
|
65 |
img = PIL.Image.open(img)
|
66 |
+
response = vis_model.generate_content([text_box_01,img])
|
67 |
return response.text
|
68 |
|
69 |
|
|
|
82 |
|
83 |
btn = gr.Button("Check This")
|
84 |
clicked = btn.click(output_query_message,
|
85 |
+
[image_box],
|
86 |
outputbox
|
87 |
).then(output_llm_response,
|
88 |
+
[image_box],
|
89 |
outputbox
|
90 |
)
|
91 |
gr.Markdown("""
|