Spaces:
Sleeping
Sleeping
import torch | |
from transformers import CLIPProcessor, CLIPModel | |
# Load the pre-trained model and processor | |
model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32") | |
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32") | |
# Define the text prompt | |
text_prompt = "a futuristic city at sunset" | |
# Process the text prompt | |
inputs = processor(text=[text_prompt], return_tensors="pt", padding=True) | |
# Generate the image | |
with torch.no_grad(): | |
outputs = model(**inputs) | |
logits_per_image = outputs.logits_per_image | |
probs = logits_per_image.softmax(dim=1) | |
# Display the generated image (this is just an example; adjust as necessary for your chatbot framework) | |
print(probs) |