Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import base64
|
|
3 |
import gradio as gr
|
4 |
from gradio_client import Client, file
|
5 |
import json
|
|
|
6 |
|
7 |
MODEL_NAME = "QWEN"
|
8 |
client_chat = os.environ.get("CHAT_URL")
|
@@ -50,19 +51,22 @@ def process_text(text_input, unit):
|
|
50 |
system=f"You are a experienced {unit} doctor AI assistant." + SYS_PROMPT,
|
51 |
api_name="/model_chat"
|
52 |
)
|
53 |
-
|
|
|
|
|
54 |
print(response)
|
55 |
return response[1][0][0]
|
56 |
|
57 |
def process_image(image_input, unit):
|
58 |
if image_input is not None:
|
|
|
59 |
print(image_input)
|
60 |
#with open(image_input, "rb") as f:
|
61 |
# base64_image = base64.b64encode(f.read()).decode("utf-8")
|
62 |
client = Client(client_vl)
|
63 |
prompt = f" You are a experienced {unit} doctor AI assistant." + SYS_PROMPT + "Help me understand what is in this picture and analysis."
|
64 |
response = client.predict(
|
65 |
-
file(
|
66 |
prompt,
|
67 |
fn_index=0
|
68 |
)
|
|
|
3 |
import gradio as gr
|
4 |
from gradio_client import Client, file
|
5 |
import json
|
6 |
+
from gradio import utils
|
7 |
|
8 |
MODEL_NAME = "QWEN"
|
9 |
client_chat = os.environ.get("CHAT_URL")
|
|
|
51 |
system=f"You are a experienced {unit} doctor AI assistant." + SYS_PROMPT,
|
52 |
api_name="/model_chat"
|
53 |
)
|
54 |
+
while not job.done():
|
55 |
+
time.sleep(0.1)
|
56 |
+
response = job.outputs()
|
57 |
print(response)
|
58 |
return response[1][0][0]
|
59 |
|
60 |
def process_image(image_input, unit):
|
61 |
if image_input is not None:
|
62 |
+
image = utils.abspath(image_input)
|
63 |
print(image_input)
|
64 |
#with open(image_input, "rb") as f:
|
65 |
# base64_image = base64.b64encode(f.read()).decode("utf-8")
|
66 |
client = Client(client_vl)
|
67 |
prompt = f" You are a experienced {unit} doctor AI assistant." + SYS_PROMPT + "Help me understand what is in this picture and analysis."
|
68 |
response = client.predict(
|
69 |
+
file(image),
|
70 |
prompt,
|
71 |
fn_index=0
|
72 |
)
|