joanrc commited on
Commit
1102979
·
verified ·
1 Parent(s): 7133af3

Upload 6 files

Browse files
Files changed (6) hide show
  1. app.py +35 -0
  2. packages.txt +9 -0
  3. real_world_im +0 -0
  4. requirements.txt +12 -0
  5. the_abbys_im +0 -0
  6. upside_down_im +0 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ from huggingface_hub import from_pretrained_fastai
4
+ import torch, os
5
+
6
+ os.environ.setdefault("OMP_NUM_THREADS", "1")
7
+ torch.set_num_threads(1)
8
+
9
+ learn = from_pretrained_fastai("joanrc/ST_Classifier")
10
+ try:
11
+ learn.to_fp32()
12
+ except:
13
+ pass
14
+ labels = learn.dls.vocab
15
+
16
+ def predict(img):
17
+ img = PILImage.create(img) # same flow as before
18
+ pred, pred_idx, probs = learn.predict(img)
19
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
20
+
21
+ title = "Stranger Things Dimension Classifier"
22
+ description = "Tries to predict at what dimension the image was taken."
23
+ examples = ['real_world_im', 'the_abbys_im', 'upside_down_im']
24
+
25
+ demo = gr.Interface(
26
+ fn=predict,
27
+ inputs=gr.Image(type="pil"),
28
+ outputs=gr.Label(num_top_classes=3),
29
+ title=title,
30
+ description=description,
31
+ examples=examples,
32
+ cache_examples=False, # <-- don’t pre-run at startup
33
+ )
34
+
35
+ demo.queue(max_size=8).launch(show_error=True, debug=True)
packages.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ ffmpeg
2
+ libsm6
3
+ libxext6
4
+ libgl1
5
+ libglx-mesa0
6
+ git
7
+ git-lfs
8
+ cmake
9
+ rsync
real_world_im ADDED
Binary file (7.12 kB). View file
 
requirements.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fastai==2.7.17
2
+ huggingface_hub[fastai]==0.24.6
3
+ timm==1.0.9
4
+ fasttransform==0.0.2
5
+ cloudpickle==3.0.0
6
+ numpy==1.26.4
7
+ pillow>=10.3.0
8
+
9
+ torch==2.2.2
10
+ torchvision==0.17.2
11
+ torchaudio==2.2.2
12
+ --extra-index-url https://download.pytorch.org/whl/cpu
the_abbys_im ADDED
Binary file (4.92 kB). View file
 
upside_down_im ADDED
Binary file (3.88 kB). View file