lwdragon commited on
Commit
9619c6f
1 Parent(s): 165dbe4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -21
app.py CHANGED
@@ -1,34 +1,18 @@
1
  import os
2
  import requests
3
- import json
4
- import time
5
  import gradio as gr
6
 
7
- from utils import get_token
8
- from obshandler import OBSHandler
9
-
10
  url = os.environ["URL_NODE"]
11
 
12
- obs = OBSHandler()
13
-
14
 
15
  def detect_image(image):
16
  print("image: ", image)
17
-
18
- user_name = "huggingface"
19
- upload_path = user_name + "/" + str(time.time()) + "/input.jpg"
20
- obs.upload_file(upload_path, image)
21
-
22
- token = get_token()
23
-
24
- requests_json = {"file_path": upload_path}
25
- headers = {"Content-Type": "application/json", "X-Auth-Token": token}
26
  resp = requests.post(url,
27
- json=requests_json,
28
- headers=headers,
29
  verify=False)
30
- resp = json.loads(resp.text)
31
- gen_url = resp["result"]
32
  return gen_url
33
 
34
 
@@ -104,4 +88,4 @@ with gr.Blocks(css=css) as demo:
104
  outputs=[image_output])
105
 
106
  demo.queue(concurrency_count=5)
107
- demo.launch(enable_queue=True)
 
1
  import os
2
  import requests
 
 
3
  import gradio as gr
4
 
 
 
 
5
  url = os.environ["URL_NODE"]
6
 
 
 
7
 
8
  def detect_image(image):
9
  print("image: ", image)
10
+ files = {"picture": open(image, "rb")}
 
 
 
 
 
 
 
 
11
  resp = requests.post(url,
12
+ files=files,
 
13
  verify=False)
14
+ resp = resp.json()
15
+ gen_url = resp["data"]["answer"]
16
  return gen_url
17
 
18
 
 
88
  outputs=[image_output])
89
 
90
  demo.queue(concurrency_count=5)
91
+ demo.launch(enable_queue=True)