Spaces:
Sleeping
Sleeping
Create GenB
Browse files
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)
|