Shilpaj commited on
Commit
aa6486e
Β·
1 Parent(s): de50636

Docs: Updated documentation

Browse files
Files changed (2) hide show
  1. README.md +70 -7
  2. app.py +15 -15
README.md CHANGED
@@ -11,16 +11,79 @@ pinned: false
11
 
12
  # ResNet50 trained on ImageNet-1K
13
 
14
- Model trained on ImageNet-1K with 1000 classes.
15
 
16
- ## Model
17
 
18
- `resnet50_imagenet1k.pth`
 
 
 
 
 
19
 
20
- ## Usage
21
 
22
- 1. Download the model from the link above.
23
- 2. Use the model in your project.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  ```python
26
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  # ResNet50 trained on ImageNet-1K
13
 
14
+ This is a ResNet50 model trained on ImageNet-1K dataset with 1000 classes. The model can classify a wide variety of images into 1000 different categories.
15
 
16
+ ## Model Details
17
 
18
+ - Architecture: ResNet50
19
+ - Dataset: ImageNet-1K
20
+ - Classes: 1000
21
+ - Input Size: 224x224 pixels
22
+ - Model File: `resnet50_imagenet1k.pth`
23
+ - Training Repository: [Link](https://github.com/pradeep6kumar/ImageNet_v4)
24
 
25
+ ## Quick Start
26
 
27
+ 1. Clone the repository:
28
+ ```bash
29
+ git clone https://huggingface.co/spaces/Shilpaj/ImageNet
30
+ cd ImageNet
31
+ ```
32
+
33
+ 2. Download the model:
34
+ ```bash
35
+ # Option 1: Using wget
36
+ wget https://huggingface.co/spaces/Shilpaj/ImageNet/blob/main/resnet50_imagenet1k.pth
37
+
38
+ # Option 2: Manual download
39
+ Download from: https://huggingface.co/spaces/Shilpaj/ImageNet/tree/main/resnet50_imagenet1k.pth
40
+ ```
41
+
42
+ 3. Install requirements:
43
+ ```bash
44
+ pip install -r requirements.txt
45
+ ```
46
+
47
+ 4. Run the demo:
48
+ ```bash
49
+ python app.py
50
+ ```
51
+
52
+ ## Usage in Your Project
53
 
54
  ```python
55
+ from inference import ImageNetClassifier
56
+
57
+ # Initialize the classifier
58
+ classifier = ImageNetClassifier('resnet50_imagenet1k.pth')
59
+
60
+ # Classify an image
61
+ image_path = 'path/to/your/image.jpg'
62
+ prediction, confidence = classifier.predict(image_path)
63
+ print(f"Prediction: {prediction}")
64
+ print(f"Confidence: {confidence:.2f}%")
65
+ ```
66
+
67
+ ## Example Images
68
+
69
+ The `assets/examples` directory contains sample images for testing:
70
+ - Bird
71
+ - Car
72
+ - Cat
73
+ - Dog
74
+ - Frog
75
+ - Horse
76
+ - Plane
77
+ - Ship
78
+ - Truck
79
+
80
+ ## Repository Structure
81
+
82
+ ```
83
+ .
84
+ β”œβ”€β”€ app.py # Gradio web interface
85
+ β”œβ”€β”€ inference.py # Model inference code
86
+ β”œβ”€β”€ requirements.txt # Python dependencies
87
+ └── assets/
88
+ └── examples/ # Example images for testing
89
+ ```
app.py CHANGED
@@ -114,14 +114,26 @@ def main():
114
  with gr.Blocks() as demo:
115
  gr.Markdown(
116
  """
117
- # ImageNet-1K trained on ResNet50v2
 
118
  """
119
  )
120
 
121
- with gr.Tab("GradCam"):
122
  gr.Markdown(
123
  """
124
- Visualize Class Activations Maps generated by the model's layer for the predicted class.
 
 
 
 
 
 
 
 
 
 
 
125
  """
126
  )
127
 
@@ -183,12 +195,6 @@ def main():
183
 
184
  # Examples section for Gradio 5.x
185
  examples = [
186
- # [
187
- # "assets/examples/dog.jpg",
188
- # 0.5, # alpha slider
189
- # 3, # top_k slider
190
- # 4 # target_layer slider
191
- # ],
192
  [
193
  "assets/examples/cat.jpg",
194
  0.5,
@@ -207,12 +213,6 @@ def main():
207
  3,
208
  4
209
  ],
210
- # [
211
- # "assets/examples/shark-plane.jpg",
212
- # 0.5,
213
- # 3,
214
- # 4
215
- # ],
216
  [
217
  "assets/examples/car.jpg",
218
  0.5,
 
114
  with gr.Blocks() as demo:
115
  gr.Markdown(
116
  """
117
+ # ResNet50 trained on ImageNet-1K
118
+ A large-scale image classification dataset with 1.2 million training images across 1,000 object categories.
119
  """
120
  )
121
 
122
+ with gr.Tab("Predictions & GradCAM"):
123
  gr.Markdown(
124
  """
125
+ View model predictions and visualize where the model is looking using GradCAM.
126
+
127
+ ## Steps to use:
128
+ 1. Upload an image or select one from the examples below
129
+ 2. Adjust the sliders (optional):
130
+ - Activation Map Transparency: Controls the blend between original image and activation map
131
+ - Number of Top Predictions: How many top class predictions to show
132
+ - Target Layer Number: Which network layer to visualize (deeper layers show higher-level features)
133
+ 3. Click "Generate GradCAM" to run the model
134
+ 4. View the results:
135
+ - Left: Original uploaded image
136
+ - Right: Model predictions and GradCAM visualization showing where the model focused
137
  """
138
  )
139
 
 
195
 
196
  # Examples section for Gradio 5.x
197
  examples = [
 
 
 
 
 
 
198
  [
199
  "assets/examples/cat.jpg",
200
  0.5,
 
213
  3,
214
  4
215
  ],
 
 
 
 
 
 
216
  [
217
  "assets/examples/car.jpg",
218
  0.5,