orrinin commited on
Commit
20f7f32
·
verified ·
1 Parent(s): 6c6a6ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -3,6 +3,7 @@ import base64
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"
@@ -56,12 +57,12 @@ def process_text(text_input, unit):
56
  time.sleep(0.1)
57
  response = job.outputs()
58
  print(response)
59
- return response[1][0][0]
60
 
61
  def process_image(image_input, unit):
62
  if image_input is not None:
63
- image = str(ABS_URL + image_input)
64
- print(image_input,image)
65
  #with open(image_input, "rb") as f:
66
  # base64_image = base64.b64encode(f.read()).decode("utf-8")
67
  client = Client(client_vl)
@@ -75,6 +76,12 @@ def process_image(image_input, unit):
75
  )
76
  print(res5)
77
 
 
 
 
 
 
 
78
  job = client.submit(
79
  res5,
80
  prompt,
@@ -82,7 +89,7 @@ def process_image(image_input, unit):
82
  )
83
  response = job.result()
84
  print(response)
85
- return response[1][0][0]
86
 
87
  def main(text_input="", image_input=None, unit=""):
88
  if text_input and image_input is None:
 
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"
 
57
  time.sleep(0.1)
58
  response = job.outputs()
59
  print(response)
60
+ return response[-1][0][0]
61
 
62
  def process_image(image_input, unit):
63
  if image_input is not None:
64
+ image = str(image_input)
65
+ print(image)
66
  #with open(image_input, "rb") as f:
67
  # base64_image = base64.b64encode(f.read()).decode("utf-8")
68
  client = Client(client_vl)
 
76
  )
77
  print(res5)
78
 
79
+ with open('res5', 'r') as f:
80
+ data = json.load(f)
81
+ data['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,
 
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: