Erfan11 commited on
Commit
0602100
1 Parent(s): 29de403

Create image_generation.py

Browse files
Files changed (1) hide show
  1. image_generation.py +14 -0
image_generation.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from PIL import Image
2
+ import torch
3
+ from transformers import CLIPProcessor, CLIPModel
4
+
5
+ def generate_image_from_text(prompt):
6
+ model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
7
+ processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
8
+
9
+ inputs = processor(text=[prompt], images=None, return_tensors="pt", padding=True)
10
+ outputs = model(**inputs)
11
+
12
+ # Dummy image return (you can integrate real image generation later)
13
+ img = Image.new("RGB", (256, 256), color="blue") # Just a placeholder image
14
+ return img