Spaces:
Running
Running
Delete README.md
Browse files
README.md
DELETED
|
@@ -1,135 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: AI-Powered Image Classification
|
| 3 |
-
emoji: 🖼️
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: indigo
|
| 6 |
-
sdk: static
|
| 7 |
-
app_file: index.html
|
| 8 |
-
pinned: false
|
| 9 |
-
models:
|
| 10 |
-
- Xenova/resnet-18
|
| 11 |
-
- Xenova/vit-base-patch16-224
|
| 12 |
-
- Xenova/clip-vit-base-patch32
|
| 13 |
-
---
|
| 14 |
-
|
| 15 |
-
# AI-Powered Image Classification
|
| 16 |
-
|
| 17 |
-
[Open the demo](https://huggingface.co/spaces/Yunpeng-26/ai-powered-image-classification) · [Student guide](https://yunpeng-26-ai-powered-image-classification.static.hf.space/how-to-start.html) · [Download the guide PDF](https://yunpeng-26-ai-powered-image-classification.static.hf.space/how-to-start.pdf)
|
| 18 |
-
|
| 19 |
-
A small teaching mini-lab for a Creative Technology / introductory AI course.
|
| 20 |
-
|
| 21 |
-
The project shows how a pretrained model can turn image classification into a capability that can be used directly inside an application. Students do not need to train a neural network for the baseline task.
|
| 22 |
-
|
| 23 |
-
## The learning story
|
| 24 |
-
|
| 25 |
-
1. Choose one of 30 examples (four are shown at random), or upload an image.
|
| 26 |
-
2. Choose a browser-compatible classifier: ResNet-18, ViT-B/16, or CLIP.
|
| 27 |
-
3. Inspect the predicted labels and confidence scores.
|
| 28 |
-
4. Keep the image fixed and switch models to compare decisions.
|
| 29 |
-
5. For CLIP, change the candidate labels and observe how the result changes.
|
| 30 |
-
6. Use the comparison log to discuss changes in the top label, score, and runtime.
|
| 31 |
-
|
| 32 |
-
## Model and data
|
| 33 |
-
|
| 34 |
-
- Task: image classification
|
| 35 |
-
- Fixed label space: ImageNet-1K for ResNet and ViT
|
| 36 |
-
- Flexible label space: user-supplied candidate descriptions for CLIP
|
| 37 |
-
- Example bank: **30 local images**, shown four at a time in the original two-by-two gallery. **Shuffle** draws another four from the same bank.
|
| 38 |
-
- Image mix: 9 animals, 9 transport examples, 10 foods, and 2 other examples. These are teaching examples, not a labeled ImageNet benchmark or an accuracy test set.
|
| 39 |
-
- Sources: the eight original examples are retained; the 22 added CC0 photographs are documented under [Image sources](#image-sources) below.
|
| 40 |
-
|
| 41 |
-
| Classifier | Hugging Face model | What to explore |
|
| 42 |
-
| --- | --- | --- |
|
| 43 |
-
| ResNet-18 | [Xenova/resnet-18](https://huggingface.co/Xenova/resnet-18) | Recommended starting point: a compact CNN with 1,000 ImageNet labels |
|
| 44 |
-
| ViT-B/16 | [Xenova/vit-base-patch16-224](https://huggingface.co/Xenova/vit-base-patch16-224) | Compare a Vision Transformer with the CNN on the same image |
|
| 45 |
-
| CLIP ViT-B/32 | [Xenova/clip-vit-base-patch32](https://huggingface.co/Xenova/clip-vit-base-patch32) | Rank your own candidate descriptions using a vision-language model |
|
| 46 |
-
|
| 47 |
-
For CLIP, enter 2-20 short candidate descriptions separated by commas or new lines. Include a description of the object you want to test: CLIP ranks only the candidates you provide. Its scores should not be interpreted as directly comparable with ResNet or ViT scores.
|
| 48 |
-
|
| 49 |
-
Top-k controls how many labels appear in the result table. Each successful run also records its image, model, top prediction, score, and elapsed time in the comparison log, which keeps the latest 12 runs for the current page session.
|
| 50 |
-
|
| 51 |
-
All three models are already trained. This demo performs inference only; no training code or GPU server is required.
|
| 52 |
-
|
| 53 |
-
## One project, one demo
|
| 54 |
-
|
| 55 |
-
- `index.html` — page structure and teaching flow
|
| 56 |
-
- `style.css` — presentation
|
| 57 |
-
- `app.js` — interaction, image handling, and result rendering
|
| 58 |
-
- `classifier.js` — the online Hugging Face model call
|
| 59 |
-
- `examples/` — 30 example images
|
| 60 |
-
- `how-to-start.html` / `how-to-start.pdf` — the existing student guide for duplicating, editing, testing, and submitting a Space
|
| 61 |
-
|
| 62 |
-
## Runtime
|
| 63 |
-
|
| 64 |
-
The Space is static. `classifier.js` imports Transformers.js from jsDelivr and creates a pipeline with a Hugging Face model ID. The first run for each model downloads its quantized model files from Hugging Face into the browser cache; later runs can reuse that cache. The selected image is processed in the browser and is not uploaded to an inference server.
|
| 65 |
-
|
| 66 |
-
This is the same online model-loading pattern used by the reference object-detection Space, with the task and models changed to image classification.
|
| 67 |
-
|
| 68 |
-
Reference object-detection Space: <https://huggingface.co/spaces/wr92-course/test>
|
| 69 |
-
|
| 70 |
-
## Student assignment
|
| 71 |
-
|
| 72 |
-
Students can duplicate this Space as a working starting point, then build their own AI mini app. They may extend image classification or adapt the project to a different AI task. A submission should make the app's purpose, input, output, and AI model or service easy to understand and demonstrate at least one working example.
|
| 73 |
-
|
| 74 |
-
In the App tab, select **How to Start** for the browser-based steps to create an account, explore the demo, duplicate the Space, edit files, build an app, explain it, and submit a public Space URL. Students are not required to train an AI model from scratch.
|
| 75 |
-
|
| 76 |
-
Higher-scoring work should deepen the selected AI task: compare or replace models, change label spaces, test another image domain, study failure cases, or improve speed and evaluation.
|
| 77 |
-
|
| 78 |
-
## Classroom check before use
|
| 79 |
-
|
| 80 |
-
Before presenting, verify that:
|
| 81 |
-
|
| 82 |
-
- every image in the 30-example bank can be selected through Shuffle;
|
| 83 |
-
- Shuffle changes the four visible examples drawn from the 30-image bank;
|
| 84 |
-
- an uploaded image can be classified;
|
| 85 |
-
- ResNet-18 and ViT-B/16 return ImageNet labels;
|
| 86 |
-
- CLIP responds to changes in candidate labels;
|
| 87 |
-
- the top-k slider changes the number of displayed predictions;
|
| 88 |
-
- the score bars and comparison log update after every successful run;
|
| 89 |
-
- the first uncached run shows download progress;
|
| 90 |
-
- the student guide opens and its PDF download works;
|
| 91 |
-
- the page works at a narrow/mobile width.
|
| 92 |
-
|
| 93 |
-
## Local preview
|
| 94 |
-
|
| 95 |
-
Run a local web server in this folder, for example:
|
| 96 |
-
|
| 97 |
-
```bash
|
| 98 |
-
python -m http.server 7860
|
| 99 |
-
```
|
| 100 |
-
|
| 101 |
-
Then open `http://localhost:7860`. Opening `index.html` directly with `file://` may block module loading.
|
| 102 |
-
|
| 103 |
-
## Image sources
|
| 104 |
-
|
| 105 |
-
<details>
|
| 106 |
-
<summary>Sources and licenses for the 22 added photographs</summary>
|
| 107 |
-
|
| 108 |
-
The 22 added example photographs below were downloaded from Wikimedia Commons file pages that identify them as CC0 1.0. They were resized to at most 1000 pixels on each side, converted to JPEG, and stored locally for reliable use in the static demo. The eight pre-existing teaching examples were already in this project before this expansion.
|
| 109 |
-
|
| 110 |
-
| Local file | Demo label | Category | Commons source | License |
|
| 111 |
-
|---|---|---|---|---|
|
| 112 |
-
| dog.jpg | Dog | Animals | [File page](https://commons.wikimedia.org/wiki/File:Golden_Retriever_%28Pet_Dog%29.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 113 |
-
| horse.jpg | Horse | Animals | [File page](https://commons.wikimedia.org/wiki/File:Horse-2166921.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 114 |
-
| elephant.jpg | Elephant | Animals | [File page](https://commons.wikimedia.org/wiki/File:Elephant_-_Jardim_Zool%C3%B3gico_de_Bras%C3%ADlia_-_DSC09798.JPG) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 115 |
-
| rabbit.jpg | Rabbit | Animals | [File page](https://commons.wikimedia.org/wiki/File:Bunny_Photo.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 116 |
-
| bird.jpg | Parrot | Animals | [File page](https://commons.wikimedia.org/wiki/File:%281218241%29_%22Parrot_bird%22_Psittaciformes_-_Amazon%2C_Brazil.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 117 |
-
| cow.jpg | Cow | Animals | [File page](https://commons.wikimedia.org/wiki/File:Cow_and_Calf.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 118 |
-
| airplane.jpg | Airplane | Transport | [File page](https://commons.wikimedia.org/wiki/File:Aleutian_Airways_plane_at_Anchorage_Airport.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 119 |
-
| car.jpg | Car | Transport | [File page](https://commons.wikimedia.org/wiki/File:Car_Photography.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 120 |
-
| bicycle.jpg | Bicycle | Transport | [File page](https://commons.wikimedia.org/wiki/File:Bicycle_10.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 121 |
-
| train.jpg | Train | Transport | [File page](https://commons.wikimedia.org/wiki/File:Rrogozhine_passenger_train.JPG) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 122 |
-
| motorcycle.jpg | Motorcycle | Transport | [File page](https://commons.wikimedia.org/wiki/File:Moto_Guzzi_Motorcycle.JPG) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 123 |
-
| boat.jpg | Boat | Transport | [File page](https://commons.wikimedia.org/wiki/File:Boat_of_Malaysia_Bomba.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 124 |
-
| truck.jpg | Truck | Transport | [File page](https://commons.wikimedia.org/wiki/File:Monochrome_vintage_truck_%28Unsplash%29.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 125 |
-
| pizza.jpg | Pizza | Food | [File page](https://commons.wikimedia.org/wiki/File:Homemade_Pizza.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 126 |
-
| hamburger.jpg | Hamburger | Food | [File page](https://commons.wikimedia.org/wiki/File:Hamburger_%28black_bg%29.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 127 |
-
| apple.jpg | Apple | Food | [File page](https://commons.wikimedia.org/wiki/File:Apple_fruit_in_illorin.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 128 |
-
| banana.jpg | Banana | Food | [File page](https://commons.wikimedia.org/wiki/File:Banana_pic.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 129 |
-
| orange.jpg | Orange | Food | [File page](https://commons.wikimedia.org/wiki/File:Oranges_a_fruit.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 130 |
-
| sandwich.jpg | Sandwich | Food | [File page](https://commons.wikimedia.org/wiki/File:Sandwich_at_Goodman%27s_Restaurant_in_Berkeley_Heights_NJ.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 131 |
-
| bread.jpg | Bread | Food | [File page](https://commons.wikimedia.org/wiki/File:Simple_Bread.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 132 |
-
| strawberry.jpg | Strawberry | Food | [File page](https://commons.wikimedia.org/wiki/File:Strawberries-3.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 133 |
-
| ice_cream.jpg | Ice cream | Food | [File page](https://commons.wikimedia.org/wiki/File:Ice_cream_flavor.jpg) | [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) |
|
| 134 |
-
|
| 135 |
-
</details>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|