miguelcarv commited on
Commit
fde2e5a
·
verified ·
1 Parent(s): 9f06ade

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +15 -18
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 torch
8
- import transformers
9
 
10
- model = transformers.AutoModelForCausalLM.from_pretrained(
11
- "miguelcarv/phi-1_5-slimorca",
12
- trust_remote_code=True
 
13
  )
14
- tokenizer = transformers.AutoTokenizer.from_pretrained("microsoft/phi-1_5")
15
 
 
16
 
17
- SYSTEM_PROMPT = "You are an AI assistant. You will be given a task. You must generate a detailed and long answer."
18
- input_text = f"""{SYSTEM_PROMPT}
19
 
20
- Instruction: Give me the first 5 prime numbers and explain what prime numbers are.
21
- Output:"""
22
 
23
- with torch.no_grad():
24
- outputs = model.generate(
25
- tokenizer(input_text, return_tensors="pt")['input_ids'],
26
- max_length=1024,
27
- num_beams = 3,
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