SombreroCat commited on
Commit
d5dc6c1
·
verified ·
1 Parent(s): 1781e06

Create GenB

Browse files
Files changed (1) hide show
  1. GenB +21 -0
GenB ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import CLIPProcessor, CLIPModel
3
+
4
+ # Load the pre-trained model and processor
5
+ model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
6
+ processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
7
+
8
+ # Define the text prompt
9
+ text_prompt = "a futuristic city at sunset"
10
+
11
+ # Process the text prompt
12
+ inputs = processor(text=[text_prompt], return_tensors="pt", padding=True)
13
+
14
+ # Generate the image
15
+ with torch.no_grad():
16
+ outputs = model(**inputs)
17
+ logits_per_image = outputs.logits_per_image
18
+ probs = logits_per_image.softmax(dim=1)
19
+
20
+ # Display the generated image (this is just an example; adjust as necessary for your chatbot framework)
21
+ print(probs)