IDS75912 commited on
Commit
9231c87
·
1 Parent(s): 8dbda3d

initial commit for gradio space

Browse files
Files changed (3) hide show
  1. README.md +6 -5
  2. app.py +28 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
- title: CTAIAnimalClassifier
3
- emoji: 🐢
4
- colorFrom: green
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 5.49.1
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Animal Classifier Space
3
+ emoji:
4
+ colorFrom: gray
5
+ colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 5.29.0
8
  app_file: app.py
9
  pinned: false
10
+ short_description: Masterclass 2025
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ import gradio as gr
3
+ import numpy as np
4
+ from huggingface_hub import hf_hub_download
5
+
6
+ # 1) download your SavedModel from the Hub
7
+ repo_id = "CTAI2025"
8
+ hf_hub_download(repo_id, filename="config.json", repo_type="model", local_dir="./model")
9
+ hf_hub_download(repo_id, filename="metadata.json", repo_type="model", local_dir="./model")
10
+ hf_hub_download(repo_id, filename="model.weights.h5", repo_type="model", local_dir="./model")
11
+
12
+ # 2) load it
13
+ model = tf.keras.models.load_model("./model")
14
+
15
+ # 3) simple preprocess + predict
16
+ CLASS_NAMES = ["cat","dog","panda"]
17
+ def predict(image):
18
+ resized_image = tf.image.resize(image, (64,64))
19
+ images_to_predict = np.expand_dims(np.array(resized_image), axis=0)
20
+ probs = model.predict(images_to_predict)[0]
21
+ return {c: float(p) for c,p in zip(CLASS_NAMES, probs)}
22
+
23
+ # 4) launch Gradio
24
+ gr.Interface(
25
+ fn=predict,
26
+ inputs=gr.Image(),
27
+ outputs=gr.Label(num_top_classes=3)
28
+ ).launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ tensorflow>=2.19.0
2
+ gradio
3
+ huggingface_hub