orrinin commited on
Commit
d706c35
·
verified ·
1 Parent(s): 909f71c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -3,7 +3,6 @@ import base64
3
  import gradio as gr
4
  from gradio_client import Client, file
5
  import time
6
- import json
7
  from gradio import utils
8
 
9
  MODEL_NAME = "QWEN"
@@ -16,8 +15,6 @@ def read(filename):
16
 
17
  SYS_PROMPT = read('system_prompt.txt')
18
 
19
- ABS_URL = "https://orrinin-hcare.hf.space/file="
20
-
21
  DESCRIPTION = '''
22
  <div>
23
  <h1 style="text-align: center;">家庭医生demo</h1>
@@ -57,7 +54,7 @@ def process_text(text_input, unit):
57
  time.sleep(0.1)
58
  response = job.result()
59
  print(response)
60
- return response[-1][1][0][1]
61
 
62
  def process_image(image_input, unit):
63
  if image_input is not None:
@@ -76,20 +73,21 @@ def process_image(image_input, unit):
76
  )
77
  print(res5)
78
 
79
- with open(res5, 'r') as f:
80
- data = json.load(f)
81
- data[0][0]['name'] = ABS_URL + image
82
- with open(res5, 'w') as f:
83
- json.dump(data, f, indent=4)
84
-
85
- job = client.submit(
86
  res5,
87
  prompt,
88
  fn_index=0
89
  )
 
 
 
 
 
 
90
  response = job.result()
91
  print(response)
92
- return response[-1][0][0]
 
93
 
94
  def main(text_input="", image_input=None, unit=""):
95
  if text_input and image_input is None:
 
3
  import gradio as gr
4
  from gradio_client import Client, file
5
  import time
 
6
  from gradio import utils
7
 
8
  MODEL_NAME = "QWEN"
 
15
 
16
  SYS_PROMPT = read('system_prompt.txt')
17
 
 
 
18
  DESCRIPTION = '''
19
  <div>
20
  <h1 style="text-align: center;">家庭医生demo</h1>
 
54
  time.sleep(0.1)
55
  response = job.result()
56
  print(response)
57
+ return response[1][0][1]
58
 
59
  def process_image(image_input, unit):
60
  if image_input is not None:
 
73
  )
74
  print(res5)
75
 
76
+ res0 = client.predict(
 
 
 
 
 
 
77
  res5,
78
  prompt,
79
  fn_index=0
80
  )
81
+
82
+ print(res0)
83
+
84
+ response = client.submit(
85
+ fn_index=1
86
+ )
87
  response = job.result()
88
  print(response)
89
+
90
+ return response[1][0][1]
91
 
92
  def main(text_input="", image_input=None, unit=""):
93
  if text_input and image_input is None: