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

Update README.md

Browse files

An vit classifier for handling noise image like this

![0b36d3c4-da8d-4fb1-bc14-a948af35f02e.jpg](https://cdn-uploads.huggingface.co/production/uploads/63891deed68e37abd59e883f/aOspZVn_4W-hUFKt5JNUj.jpeg)

It has limitation inbetween clear and noise

```
from datasets import load_dataset
from PIL import Image
from transformers import ViTImageProcessor, ViTForImageClassification, TrainingArguments, Trainer
import torch
import numpy as np
from datasets import load_metric
import os
import shutil

model_name_or_path = 'lrzjason/noise-classifier'
image_processor = ViTImageProcessor.from_pretrained(model_name_or_path)
model = ViTForImageClassification.from_pretrained(model_name_or_path)

input_dir = ''
file = 'b5b457f4-5b52-4d68-be1b-9a2f557465f6.jpg'
image = Image.open(os.path.join(input_dir, file))

inputs = image_processor(image, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits

# model predicts one of the 1000 ImageNet classes
predicted_label = logits.argmax(-1).item()
```

Files changed (1) hide show
  1. README.md +1 -1
README.md CHANGED
@@ -1,3 +1,3 @@
1
  ---
2
  license: apache-2.0
3
- ---
 
1
  ---
2
  license: apache-2.0
3
+ ---