AUST001 commited on
Commit
9c76c69
·
1 Parent(s): 3db3ca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -1,10 +1,18 @@
1
  import gradio as gr
2
  import cv2
 
 
 
 
 
3
 
4
  def to_black(text):
5
- if text=='老公我爱你'.encode('utf-8'):
6
- output = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
7
- return output
 
 
 
8
 
9
  interface = gr.Interface(fn=to_black, inputs="text", outputs="image")
10
  interface.launch()
 
1
  import gradio as gr
2
  import cv2
3
+ import cv2
4
+ import urllib.request
5
+ import numpy as np
6
+ # 图片url
7
+ url = 'http://114.96.110.174:6278/photo/11.jpg'
8
 
9
  def to_black(text):
10
+ if text=='love':
11
+ # 从url中获取图片
12
+ resp = urllib.request.urlopen(url)
13
+ image = np.asarray(bytearray(resp.read()), dtype="uint8")
14
+ image = cv2.imdecode(image, cv2.IMREAD_COLOR)
15
+ return image
16
 
17
  interface = gr.Interface(fn=to_black, inputs="text", outputs="image")
18
  interface.launch()