jiechau commited on
Commit
6b56a29
1 Parent(s): 64e0bbd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +8 -2
README.md CHANGED
@@ -30,11 +30,17 @@ Determine whether online sales products are adult content. Input: image content,
30
 
31
  # use transformers pipeline
32
  ```python
33
- from transformers import pipeline
34
- pipe = pipeline("image-classification", model="jiechau/adult-content-classifier")
 
 
 
 
35
  q = 'https://xxx.xxx.xxx/images/xxx/xxx.webp'
36
  q = 'https://xxx.xxx.xxx/images/xxx/xxx.jpg'
37
  result = pipe(q)
38
  print(result)
 
39
  # [{'label': 'adult_成人商品', 'score': 0.7516837120056152}, {'label': 'regular_一般商品', 'score': 0.2475457787513733}, {'label': 'unknown', 'score': 0.0007705678581260145}]
 
40
  ```
 
30
 
31
  # use transformers pipeline
32
  ```python
33
+ from transformers import pipeline, AutoConfig
34
+ pipe = pipeline("image-classification", model="jiechau/adult-content-identify-image")
35
+ config = AutoConfig.from_pretrained("jiechau/adult-content-identify-image")
36
+ label2id = config.label2id
37
+ id2label = config.id2label
38
+
39
  q = 'https://xxx.xxx.xxx/images/xxx/xxx.webp'
40
  q = 'https://xxx.xxx.xxx/images/xxx/xxx.jpg'
41
  result = pipe(q)
42
  print(result)
43
+ print(label2id[result[0]['label']])
44
  # [{'label': 'adult_成人商品', 'score': 0.7516837120056152}, {'label': 'regular_一般商品', 'score': 0.2475457787513733}, {'label': 'unknown', 'score': 0.0007705678581260145}]
45
+ # 1
46
  ```