lelouch0110 commited on
Commit
ab39072
·
verified ·
1 Parent(s): 98a44fe

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gradio as gr
2
  import tensorflow as tf
3
  import requests
@@ -30,15 +31,22 @@ if gpus:
30
 
31
 
32
  def classify_image(inp):
 
33
  # Convert to PIL Image if we have a numpy array
34
  image = None
35
  if isinstance(inp, np.ndarray):
36
  image = Image.fromarray(inp)
 
 
37
  if isinstance(inp, str) and (inp.startswith("http://") or inp.startswith("https://")):
38
  response = requests.get(inp)
39
  response.raise_for_status()
40
  image = Image.open(BytesIO(response.content))
 
 
41
  else:
 
 
42
  image = inp
43
 
44
  # Resize image to 224x224
 
1
+ from io import BytesIO
2
  import gradio as gr
3
  import tensorflow as tf
4
  import requests
 
31
 
32
 
33
  def classify_image(inp):
34
+ Warning(inp)
35
  # Convert to PIL Image if we have a numpy array
36
  image = None
37
  if isinstance(inp, np.ndarray):
38
  image = Image.fromarray(inp)
39
+ Warning("Image is a numpy array")
40
+ Warning(image)
41
  if isinstance(inp, str) and (inp.startswith("http://") or inp.startswith("https://")):
42
  response = requests.get(inp)
43
  response.raise_for_status()
44
  image = Image.open(BytesIO(response.content))
45
+ Warning("Image is url")
46
+ Warning(image)
47
  else:
48
+ Warning("Image is ???")
49
+ Warning(image)
50
  image = inp
51
 
52
  # Resize image to 224x224