Add pipeline tag and usage example, remove library_tag

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +42 -3
README.md CHANGED
@@ -1,17 +1,56 @@
1
  ---
 
 
2
  tags:
3
  - image-classification
4
  - timm
5
- library_tag: timm
6
- license: mit
7
- library_name: timm
8
  ---
 
9
  # LSNet: See Large, Focus Small
10
 
11
  Paper: https://arxiv.org/abs/2503.23135
12
 
13
  Code: https://github.com/THU-MIG/lsnet
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ```bibtex
16
  @misc{wang2025lsnetlargefocussmall,
17
  title={LSNet: See Large, Focus Small},
 
1
  ---
2
+ library_name: timm
3
+ license: mit
4
  tags:
5
  - image-classification
6
  - timm
 
 
 
7
  ---
8
+
9
  # LSNet: See Large, Focus Small
10
 
11
  Paper: https://arxiv.org/abs/2503.23135
12
 
13
  Code: https://github.com/THU-MIG/lsnet
14
 
15
+ ## Usage
16
+
17
+ ```python
18
+ import timm
19
+ import torch
20
+ from PIL import Image
21
+ import requests
22
+ from timm.data import resolve_data_config, create_transform
23
+
24
+ # Load the model
25
+ model = timm.create_model(
26
+ 'hf_hub:jameslahm/lsnet_b',
27
+ pretrained=True
28
+ )
29
+ model.eval()
30
+
31
+ # Load and transform image
32
+ # Example using a URL:
33
+ url = 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
34
+ img = Image.open(requests.get(url, stream=True).raw)
35
+
36
+ config = resolve_data_config({}, model=model)
37
+ transform = create_transform(**config)
38
+ input_tensor = transform(img).unsqueeze(0) # transform and add batch dimension
39
+
40
+ # Make prediction
41
+ with torch.no_grad():
42
+ output = model(input_tensor)
43
+ probabilities = torch.nn.functional.softmax(output[0], dim=0)
44
+
45
+ # Get top 5 predictions
46
+ top5_prob, top5_catid = torch.topk(probabilities, 5)
47
+ # Assuming you have imagenet labels list 'imagenet_labels'
48
+ # for i in range(top5_prob.size(0)):
49
+ # print(imagenet_labels[top5_catid[i]], top5_prob[i].item())
50
+ ```
51
+
52
+ ## Citation
53
+
54
  ```bibtex
55
  @misc{wang2025lsnetlargefocussmall,
56
  title={LSNet: See Large, Focus Small},