orrinin commited on
Commit
d62a0b0
·
verified ·
1 Parent(s): 37c0d2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -39,12 +39,13 @@ footer {
39
 
40
 
41
  LICENSE = '当前采用 ' + MODEL_NAME + ' 模型,请主动移除个人信息,注意隐私保护🔔'
 
42
 
43
  local_data = threading.local()
44
  def init_data():
45
- if not hasattr(local_data, 'results') and not hasattr(local_data, 'json_path'):
46
  local_data.results = ""
47
- local_data.json_path = ""
48
 
49
  def process_text(text_input, unit):
50
  init_data()
@@ -58,11 +59,13 @@ def process_text(text_input, unit):
58
  )
59
  response = job.result()
60
  local_data.results = response[1][0][1]
61
-
 
62
 
63
 
64
  def process_image(image_input, unit):
65
  init_data()
 
66
  if image_input is not None:
67
  image = str(image_input)
68
  print(image)
@@ -86,21 +89,21 @@ def process_image(image_input, unit):
86
  )
87
 
88
  print(res0)
89
- local_data.json_path = res0
90
 
91
  def update():
92
- init_data()
93
  job = client.submit(
94
- local_data.json_path,
95
  fn_index=1
96
  )
97
  response = job.result()
98
  with open(response, 'r') as f:
99
  data = json.load(f)
100
  print(data)
101
- local_data.results = data[-1][1]
102
- local_data.results = "正在分析....."
103
  threading.Thread(target=update).start()
 
104
 
105
 
106
  def fetch_result():
@@ -119,7 +122,6 @@ def main(text_input="", image_input=None, unit=""):
119
  process_text(text_input, unit)
120
  elif image_input is not None:
121
  process_image(image_input, unit)
122
- return local_data.results
123
 
124
  with gr.Blocks(css=css, title="家庭医生AI助手", theme="soft") as iface:
125
  with gr.Accordion(""):
 
39
 
40
 
41
  LICENSE = '当前采用 ' + MODEL_NAME + ' 模型,请主动移除个人信息,注意隐私保护🔔'
42
+ json_path = ""
43
 
44
  local_data = threading.local()
45
  def init_data():
46
+ if not hasattr(local_data, 'results'):
47
  local_data.results = ""
48
+
49
 
50
  def process_text(text_input, unit):
51
  init_data()
 
59
  )
60
  response = job.result()
61
  local_data.results = response[1][0][1]
62
+ return local_data.results
63
+
64
 
65
 
66
  def process_image(image_input, unit):
67
  init_data()
68
+ response = ""
69
  if image_input is not None:
70
  image = str(image_input)
71
  print(image)
 
89
  )
90
 
91
  print(res0)
92
+ json_path = res0
93
 
94
  def update():
 
95
  job = client.submit(
96
+ json_path,
97
  fn_index=1
98
  )
99
  response = job.result()
100
  with open(response, 'r') as f:
101
  data = json.load(f)
102
  print(data)
103
+ response = data[-1][1]
104
+ local_data.results = response
105
  threading.Thread(target=update).start()
106
+ return "正在分析....."
107
 
108
 
109
  def fetch_result():
 
122
  process_text(text_input, unit)
123
  elif image_input is not None:
124
  process_image(image_input, unit)
 
125
 
126
  with gr.Blocks(css=css, title="家庭医生AI助手", theme="soft") as iface:
127
  with gr.Accordion(""):