Araeynn commited on
Commit
17dcf9a
·
verified ·
1 Parent(s): c0e7a29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -16
app.py CHANGED
@@ -1,25 +1,12 @@
1
- from huggingface_hub import from_pretrained_keras
2
  import gradio as gr
3
- import tensorflow as tf
4
-
5
- model = from_pretrained_keras("araeynn/validation_model")
6
-
7
 
8
  def image_classifier(inp):
9
  class_names = ["0", "1"]
10
  inp.save("why.png")
11
  sunflower_path = "why.png"
12
- img = tf.keras.utils.load_img(sunflower_path, target_size=(256, 256))
13
- img_array = tf.keras.utils.img_to_array(img)
14
- img_array = tf.expand_dims(img_array, 0) # Create a batch
15
-
16
- predictions = model.predict(img_array)
17
- score = tf.nn.softmax(predictions)
18
- r = {}
19
- print(score)
20
- for s in score:
21
- print(s)
22
- r = {"0":score, "1":1 - score}
23
  return r
24
 
25
 
 
 
1
  import gradio as gr
2
+ from huggingface_hub import AsyncInferenceClient
3
+ client = AsyncInferenceClient()
 
 
4
 
5
  def image_classifier(inp):
6
  class_names = ["0", "1"]
7
  inp.save("why.png")
8
  sunflower_path = "why.png"
9
+ r = await client.zero_shot_image_classification("why.png", labels=["mouth", "other"])
 
 
 
 
 
 
 
 
 
 
10
  return r
11
 
12