Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import
|
| 3 |
|
| 4 |
-
# Load
|
| 5 |
-
model_name = "
|
| 6 |
-
|
| 7 |
-
model =
|
| 8 |
|
| 9 |
def generate_3d_image(text_prompt):
|
| 10 |
# Encode the text prompt
|
| 11 |
-
|
| 12 |
|
| 13 |
# Generate image from text prompt
|
| 14 |
-
output = model.
|
| 15 |
|
| 16 |
-
|
| 17 |
-
output_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 18 |
-
|
| 19 |
-
return output_text
|
| 20 |
|
| 21 |
# Create a Gradio interface for generating 3D images
|
| 22 |
iface = gr.Interface(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import CLIPProcessor, CLIPModel
|
| 3 |
|
| 4 |
+
# Load CLIP model and processor
|
| 5 |
+
model_name = "openai/clip-vit-base-patch32"
|
| 6 |
+
processor = CLIPProcessor.from_pretrained(model_name)
|
| 7 |
+
model = CLIPModel.from_pretrained(model_name)
|
| 8 |
|
| 9 |
def generate_3d_image(text_prompt):
|
| 10 |
# Encode the text prompt
|
| 11 |
+
inputs = processor(text=text_prompt, return_tensors="pt")
|
| 12 |
|
| 13 |
# Generate image from text prompt
|
| 14 |
+
output = model.get_image(inputs.pixel_values)
|
| 15 |
|
| 16 |
+
return "Image generated successfully based on the text prompt."
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Create a Gradio interface for generating 3D images
|
| 19 |
iface = gr.Interface(
|