miguelcarv
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -4,30 +4,27 @@ This model was trained with the intent to quickyl classify whether or not an ima
|
|
4 |
# Model Details
|
5 |
## How to Get Started with the Model
|
6 |
```python
|
7 |
-
import
|
8 |
-
import
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
13 |
)
|
14 |
-
tokenizer = transformers.AutoTokenizer.from_pretrained("microsoft/phi-1_5")
|
15 |
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
Output:"""
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
eos_token_id = tokenizer.eos_token_id
|
29 |
-
)
|
30 |
-
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
31 |
```
|
32 |
# Training Details
|
33 |
- Trained for three epochs
|
|
|
4 |
# Model Details
|
5 |
## How to Get Started with the Model
|
6 |
```python
|
7 |
+
from PIL import Image
|
8 |
+
import requests
|
9 |
|
10 |
+
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
11 |
+
|
12 |
+
model = AutoModelForImageClassification.from_pretrained(
|
13 |
+
"miguelcarv/resnet-50-text-detector",
|
14 |
)
|
|
|
15 |
|
16 |
+
processor = AutoImageProcessor.from_pretrained("microsoft/resnet-50", do_resize=False)
|
17 |
|
18 |
+
url = "http://images.cocodataset.org/train2017/000000044520.jpg"
|
19 |
+
image = Image.open(requests.get(url, stream=True).raw).convert('RGB').resize((256,256))
|
20 |
|
21 |
+
inputs = processor(image, return_tensors="pt").pixel_values
|
|
|
22 |
|
23 |
+
outputs = model(inputs)
|
24 |
+
logits_per_image = outputs.logits
|
25 |
+
probs = logits_per_image.softmax(dim=1)
|
26 |
+
print(probs)
|
27 |
+
# tensor([[0.1149, 0.8851]])
|
|
|
|
|
|
|
28 |
```
|
29 |
# Training Details
|
30 |
- Trained for three epochs
|