Philipp Allgeuer commited on
Commit
e0f4d55
·
1 Parent(s): 1c9b44b

Configure app visual appearance

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ sample_images/*.jpg filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,14 +1,47 @@
1
  ---
2
- title: Novic
3
- emoji: 🏆
4
- colorFrom: yellow
 
 
5
  colorTo: yellow
6
  sdk: gradio
 
7
  sdk_version: 5.35.0
8
  app_file: app.py
9
- pinned: false
10
- license: gpl-3.0
11
- short_description: Prompt-free open vocabulary classification of any image
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: "NOVIC: Unconstrained Open Vocabulary Image Classification"
3
+ short_description: "Prompt-free open vocabulary classification of any image"
4
+ license: gpl-3.0
5
+ emoji: 🖼️
6
+ colorFrom: green
7
  colorTo: yellow
8
  sdk: gradio
9
+ python_version: 3.10
10
  sdk_version: 5.35.0
11
  app_file: app.py
12
+ fullWidth: true
13
+ header: default
14
+ models: []
15
+ tags:
16
+ - prompt-free
17
+ - open vocabulary
18
+ - image classification
19
+ - computer vision
20
+ - identification
21
+ - generative
22
+ pinned: true
23
+ disable_embedding: false
24
+ preload_from_hub: []
25
  ---
26
 
27
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
28
+
29
+ To run the Gradio space locally, you first create a sandboxed Python 3.10 environment:
30
+ ```bash
31
+ python -m venv .venv # <-- Python 3.10
32
+ source .venv/bin/activate
33
+ # OR...
34
+ conda create -n novic_spaces python=3.10
35
+ conda activate novic_spaces
36
+ ```
37
+ Then install `gradio` and any further requirements:
38
+ ```bash
39
+ pip install gradio==5.35.0 -r requirements.txt
40
+ ```
41
+ Now run the Gradio application:
42
+ ```bash
43
+ ./app.py
44
+ # OR...
45
+ gradio app.py
46
+ ```
47
+ Open in a browser the URL that the application is running on (as shown in the CLI output), e.g. [http://127.0.0.1:7860](http://127.0.0.1:7860).
app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # NOVIC Gradio Space
3
+
4
+ # Imports
5
+ import os
6
+ import glob
7
+ import random
8
+ from typing import Optional
9
+ import PIL.Image
10
+ import gradio as gr
11
+
12
+ # Sample images
13
+ IMAGE_EXTS = ('jpg', 'jpeg', 'png', 'webp')
14
+ SAMPLE_IMAGES = sorted(image_path for image_ext in IMAGE_EXTS for image_path in glob.glob(os.path.join('sample_images', f'*.{image_ext}')))
15
+
16
+ # Classify image
17
+ def classify_image(image: Optional[PIL.Image.Image]) -> dict[str, float]:
18
+
19
+ if image is None:
20
+ return {}
21
+
22
+ labels = ('thing', 'item', 'stuff', 'object', 'entity')
23
+ probs = [random.random() for _ in labels]
24
+ prob_sum = sum(probs)
25
+ return {label: prob / prob_sum for label, prob in zip(labels, probs)}
26
+
27
+ # Gradio UI
28
+ demo = gr.Interface(
29
+ fn=classify_image,
30
+ inputs=gr.Image(
31
+ height=400,
32
+ image_mode='RGB',
33
+ type='pil',
34
+ label='Input image',
35
+ show_label=True,
36
+ interactive=True,
37
+ show_fullscreen_button=True,
38
+ ),
39
+ outputs=gr.Label(
40
+ num_top_classes=3,
41
+ label='Predicted label',
42
+ show_label=True,
43
+ show_heading=True,
44
+ ),
45
+ examples=SAMPLE_IMAGES,
46
+ examples_per_page=20,
47
+ live=True,
48
+ title="🖼️ NOVIC: Unconstrained Open Vocabulary Image Classification",
49
+ description="*Select* an image from the examples shown below **OR** *Upload* an image file from your computer **OR** *Capture* an image using an attached camera **OR** *Copy-paste* an image from your clipboard. The label predictions on the right will update automatically!",
50
+ article=None,
51
+ theme=None,
52
+ flagging_mode='never',
53
+ analytics_enabled=True,
54
+ api_name='classify',
55
+ allow_duplication=False,
56
+ clear_btn=gr.Button(value='Clear', variant='secondary'),
57
+ show_progress='full',
58
+ fill_width=False,
59
+ deep_link=True,
60
+ )
61
+
62
+ # Run demo
63
+ if __name__ == '__main__':
64
+ demo.launch()
65
+ # EOF
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ pillow
sample_images/01_rhodesian_ridgeback.jpg ADDED

Git LFS Details

  • SHA256: ac055561dcdf43a26c944263c3249349212c37904854c21db885d8943b446ee0
  • Pointer size: 130 Bytes
  • Size of remote file: 12.5 kB
sample_images/02_daffodil.jpg ADDED

Git LFS Details

  • SHA256: 2843ae4241f42498a6595eda50e5cefff48a6e63d5bd5ac4c061795e84bfbb02
  • Pointer size: 131 Bytes
  • Size of remote file: 143 kB
sample_images/03_stuffed_toy.jpg ADDED

Git LFS Details

  • SHA256: 7d1ad02d43d8e6b37a5f7144c4a553d657d20f32026b72d8a66414699801179e
  • Pointer size: 130 Bytes
  • Size of remote file: 19 kB
sample_images/04_banknote.jpg ADDED

Git LFS Details

  • SHA256: 65cca1ef076569788c72655aba137251c6ac1d1f7469e03663d7ce6a8c8663ac
  • Pointer size: 130 Bytes
  • Size of remote file: 33.7 kB
sample_images/05_magic_lantern.jpg ADDED

Git LFS Details

  • SHA256: d28c68fb02c0e98900e1c5cbfb865a3c7e88e52143ef4829d05d8d4c3ddef9f7
  • Pointer size: 130 Bytes
  • Size of remote file: 23.4 kB
sample_images/06_roof_rack.jpg ADDED

Git LFS Details

  • SHA256: 1d5be535a7c2a7a06ad8cdb0f40809d49d56632e7cca22c37746afeb07345e1b
  • Pointer size: 131 Bytes
  • Size of remote file: 106 kB
sample_images/07_armadillo.jpg ADDED

Git LFS Details

  • SHA256: 6e602f9a8ee2dc01e70958276ea983b0a5727c9ac0d8faf72be2be187fbad813
  • Pointer size: 130 Bytes
  • Size of remote file: 55.3 kB
sample_images/08_church_aurora.jpg ADDED

Git LFS Details

  • SHA256: ac17577a9721be39e6edaa757278ac0d6055fead0538330f3b6021ae09db434f
  • Pointer size: 130 Bytes
  • Size of remote file: 22.9 kB
sample_images/09_spur.jpg ADDED

Git LFS Details

  • SHA256: bdaefa7a75e72b7e0b650e12eb22610e05cd992ac097a4e8982953b20b9b5c7e
  • Pointer size: 130 Bytes
  • Size of remote file: 27 kB
sample_images/10_red_panda.jpg ADDED

Git LFS Details

  • SHA256: 7cd618232d3b426c7a334f68ec435a0b39560c24e4688b78724739432e77e853
  • Pointer size: 130 Bytes
  • Size of remote file: 35.3 kB
sample_images/11_bicycle_rack.jpg ADDED

Git LFS Details

  • SHA256: f7daaa283577dcec53642ce61b0e4e8bf544ba9e68190ee1b940df4d3620d87f
  • Pointer size: 131 Bytes
  • Size of remote file: 106 kB
sample_images/12_pedestrian_crossing.jpg ADDED

Git LFS Details

  • SHA256: b4a37e4fad37b1e26289d2ee687f6042387683e6f7b4635230e700af94c57e46
  • Pointer size: 130 Bytes
  • Size of remote file: 50.2 kB
sample_images/13_compression_bandage.jpg ADDED

Git LFS Details

  • SHA256: 420a9f3a5363bf55a7a714c0cb663ee1c8790c26f7ba465cae3f1278374c53b4
  • Pointer size: 130 Bytes
  • Size of remote file: 23.1 kB
sample_images/14_hearing_aid.jpg ADDED

Git LFS Details

  • SHA256: 6165d0a16d419f9ff50e3d0604cbb7716420dac74aade9a0c1a92fe1ba8a314b
  • Pointer size: 130 Bytes
  • Size of remote file: 25.3 kB
sample_images/15_praying_mantis.jpg ADDED

Git LFS Details

  • SHA256: 3ab04409cc73c6c7fd43418fe47d45ea701f22ca8a79986796059028525d04c5
  • Pointer size: 130 Bytes
  • Size of remote file: 14.3 kB
sample_images/16_hippopotamus.jpg ADDED

Git LFS Details

  • SHA256: b26791585ba35bfd56e53dd4328277866f37776896f3c0c78569dfe013ad71aa
  • Pointer size: 130 Bytes
  • Size of remote file: 32.2 kB
sample_images/17_wreath.jpg ADDED

Git LFS Details

  • SHA256: ecf04260b2233d145bb6b2c91e036e6538a38d7109832c8c7dcdf6ddd03fac4e
  • Pointer size: 130 Bytes
  • Size of remote file: 47.4 kB