Update app.py
Browse files
app.py
CHANGED
@@ -44,14 +44,15 @@ LICENSE = '采用 ' + MODEL_NAME + ' 模型'
|
|
44 |
def process_text(text_input, unit):
|
45 |
client = Client(client_chat)
|
46 |
client.predict(
|
47 |
-
system=f"
|
48 |
api_name="/modify_system_session"
|
49 |
)
|
50 |
response = client.predict(
|
51 |
-
query=text_input,
|
|
|
52 |
api_name="/model_chat"
|
53 |
)
|
54 |
-
|
55 |
|
56 |
|
57 |
def encode_image_to_base64(image_input):
|
@@ -63,17 +64,17 @@ def encode_image_to_base64(image_input):
|
|
63 |
def process_image(image_input, unit):
|
64 |
if image_input is not None:
|
65 |
print(image_input)
|
66 |
-
with open(image_input, "rb") as f:
|
67 |
-
|
68 |
client = Client(client_vl)
|
69 |
# base64_image = encode_image_to_base64(image_input)
|
70 |
prompt = f" You are a experienced {unit} doctor AI assistant." + SYS_PROMPT + "Help me understand what is in this picture and analysis."
|
71 |
response = client.predict(
|
72 |
-
|
73 |
prompt,
|
74 |
fn_index=0
|
75 |
)
|
76 |
-
|
77 |
|
78 |
|
79 |
def main(text_input="", image_input=None, unit=""):
|
@@ -82,7 +83,7 @@ def main(text_input="", image_input=None, unit=""):
|
|
82 |
elif image_input is not None:
|
83 |
return process_image(image_input,unit)
|
84 |
|
85 |
-
with gr.Blocks(theme='
|
86 |
with gr.Accordion(""):
|
87 |
gr.Markdown(DESCRIPTION)
|
88 |
unit = gr.Dropdown(label="🩺科室", value='中医科', elem_id="units",
|
@@ -93,7 +94,7 @@ with gr.Blocks(theme='shivi/calm_seafoam', css=css, title="家庭医生AI助手"
|
|
93 |
with gr.Row():
|
94 |
output_box = gr.Markdown(label="分析") # Create an output textbox
|
95 |
with gr.Row():
|
96 |
-
image_input = gr.Image(type="
|
97 |
text_input = gr.Textbox(label="输入") # Create a text input box
|
98 |
with gr.Row():
|
99 |
submit_btn = gr.Button("🚀 确认") # Create a submit button
|
|
|
44 |
def process_text(text_input, unit):
|
45 |
client = Client(client_chat)
|
46 |
client.predict(
|
47 |
+
system=f"You are a experienced {unit} doctor AI assistant." + SYS_PROMPT,
|
48 |
api_name="/modify_system_session"
|
49 |
)
|
50 |
response = client.predict(
|
51 |
+
query=str(text_input),
|
52 |
+
history=None,
|
53 |
api_name="/model_chat"
|
54 |
)
|
55 |
+
print(response)
|
56 |
|
57 |
|
58 |
def encode_image_to_base64(image_input):
|
|
|
64 |
def process_image(image_input, unit):
|
65 |
if image_input is not None:
|
66 |
print(image_input)
|
67 |
+
#with open(image_input, "rb") as f:
|
68 |
+
# base64_image = base64.b64encode(f.read()).decode("utf-8")
|
69 |
client = Client(client_vl)
|
70 |
# base64_image = encode_image_to_base64(image_input)
|
71 |
prompt = f" You are a experienced {unit} doctor AI assistant." + SYS_PROMPT + "Help me understand what is in this picture and analysis."
|
72 |
response = client.predict(
|
73 |
+
image_input,
|
74 |
prompt,
|
75 |
fn_index=0
|
76 |
)
|
77 |
+
print(response)
|
78 |
|
79 |
|
80 |
def main(text_input="", image_input=None, unit=""):
|
|
|
83 |
elif image_input is not None:
|
84 |
return process_image(image_input,unit)
|
85 |
|
86 |
+
with gr.Blocks(theme='soft', css=css, title="家庭医生AI助手") as iface:
|
87 |
with gr.Accordion(""):
|
88 |
gr.Markdown(DESCRIPTION)
|
89 |
unit = gr.Dropdown(label="🩺科室", value='中医科', elem_id="units",
|
|
|
94 |
with gr.Row():
|
95 |
output_box = gr.Markdown(label="分析") # Create an output textbox
|
96 |
with gr.Row():
|
97 |
+
image_input = gr.Image(type="str", label="上传图片") # Create an image upload button
|
98 |
text_input = gr.Textbox(label="输入") # Create a text input box
|
99 |
with gr.Row():
|
100 |
submit_btn = gr.Button("🚀 确认") # Create a submit button
|