JohnTan38 commited on
Commit
d8d8c0e
1 Parent(s): 051b0e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
app.py CHANGED
@@ -1,16 +1,12 @@
1
- from transformers import ViTImageProcessor, ViTForImageClassification
2
- from PIL import Image
3
- import requests
4
 
5
- url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
6
- image = Image.open(requests.get(url, stream=True).raw)
7
 
8
- processor = ViTImageProcessor.from_pretrained('google/vit-base-patch16-224')
9
- model = ViTForImageClassification.from_pretrained('google/vit-base-patch16-224')
10
 
11
- inputs = processor(images=image, return_tensors="pt")
12
- outputs = model(**inputs)
13
- logits = outputs.logits
14
- # model predicts one of the 1000 ImageNet classes
15
- predicted_class_idx = logits.argmax(-1).item()
16
- print("Predicted class:", model.config.id2label[predicted_class_idx])
 
1
+ from transformers import AutoModelForCausalLM, AutoTokenizer
 
 
2
 
3
+ model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
4
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
5
 
6
+ model = AutoModelForCausalLM.from_pretrained(model_id)
 
7
 
8
+ text = "Hello my name is"
9
+ inputs = tokenizer(text, return_tensors="pt")
10
+
11
+ outputs = model.generate(**inputs, max_new_tokens=20)
12
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))