lrzjason commited on
Commit
18e84b9
1 Parent(s): 94a42b3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -1
README.md CHANGED
@@ -1,3 +1,34 @@
1
  ---
2
  license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ ---
4
+ An vit classifier for handling noise image like this
5
+
6
+ ![0b36d3c4-da8d-4fb1-bc14-a948af35f02e.jpg](https://cdn-uploads.huggingface.co/production/uploads/63891deed68e37abd59e883f/aOspZVn_4W-hUFKt5JNUj.jpeg)
7
+
8
+ It has limitation inbetween clear and noise
9
+
10
+ ```
11
+ from datasets import load_dataset
12
+ from PIL import Image
13
+ from transformers import ViTImageProcessor, ViTForImageClassification, TrainingArguments, Trainer
14
+ import torch
15
+ import numpy as np
16
+ from datasets import load_metric
17
+ import os
18
+ import shutil
19
+
20
+ model_name_or_path = 'lrzjason/noise-classifier'
21
+ image_processor = ViTImageProcessor.from_pretrained(model_name_or_path)
22
+ model = ViTForImageClassification.from_pretrained(model_name_or_path)
23
+
24
+ input_dir = ''
25
+ file = 'b5b457f4-5b52-4d68-be1b-9a2f557465f6.jpg'
26
+ image = Image.open(os.path.join(input_dir, file))
27
+
28
+ inputs = image_processor(image, return_tensors="pt")
29
+ with torch.no_grad():
30
+ logits = model(**inputs).logits
31
+
32
+ # model predicts one of the 1000 ImageNet classes
33
+ predicted_label = logits.argmax(-1).item()
34
+ ```