Onix4oDedy commited on
Commit
7a46d3b
·
verified ·
1 Parent(s): 9900537

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -39,7 +39,7 @@ def solve_captcha(data_bytes: bytes = None, file_name: str = None):
39
  return answ, accuracy
40
 
41
 
42
- def decode_img_bytes(data_bytes: bytes):
43
  # same actions, as for tensorflow
44
  image = cv2.imdecode(np.asarray(bytearray(data_bytes), dtype=np.uint8), 1)
45
  image: "np.ndarray" = image.astype(np.float32) / 255.
@@ -50,7 +50,7 @@ def solve_captcha(data_bytes: bytes = None, file_name: str = None):
50
  image = np.array([image])
51
  return image
52
 
53
- def decode_img(nump_array):
54
  # same actions, as for tensorflow
55
  #image = cv2.imdecode(nump_array, 1)
56
  image: "np.ndarray" = nump_array.astype(np.float32) / 255.
@@ -79,11 +79,13 @@ def solve_captcha(data_bytes: bytes = None, file_name: str = None):
79
  def image_classifier(inp):
80
  if inp is None:
81
  return "Не загружена картинка"
82
- print('INPUT GOT>>>', inp.dtype)
83
  #gradio img inp - numpy ndarray
84
-
85
- result = solve_captcha(inp)
 
 
86
  return result
87
  #gr.Image(type="pil"),
88
- demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
89
  demo.launch()
 
39
  return answ, accuracy
40
 
41
 
42
+ def decode_img(data_bytes: bytes):
43
  # same actions, as for tensorflow
44
  image = cv2.imdecode(np.asarray(bytearray(data_bytes), dtype=np.uint8), 1)
45
  image: "np.ndarray" = image.astype(np.float32) / 255.
 
50
  image = np.array([image])
51
  return image
52
 
53
+ def decode_img_array(nump_array):
54
  # same actions, as for tensorflow
55
  #image = cv2.imdecode(nump_array, 1)
56
  image: "np.ndarray" = nump_array.astype(np.float32) / 255.
 
79
  def image_classifier(inp):
80
  if inp is None:
81
  return "Не загружена картинка"
82
+ print('INPUT GOT>>>', inp)
83
  #gradio img inp - numpy ndarray
84
+ img_byte_arr = io.BytesIO()
85
+ inp.save(img_byte_arr, format='PNG')
86
+ img_byte_arr = img_byte_arr.getvalue
87
+ result = solve_captcha(img_byte_arr)
88
  return result
89
  #gr.Image(type="pil"),
90
+ demo = gr.Interface(fn=image_classifier, inputs= gr.Image(type="pil"), outputs="label")
91
  demo.launch()