Spaces:
Sleeping
Sleeping
Commit
•
9a435e2
1
Parent(s):
414dca8
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ if st.button("Generate Image") and text:
|
|
17 |
text_features = clip_processor(text, return_tensors="pt", padding=True)
|
18 |
|
19 |
# Load an example image from the web (replace this with your image loading logic)
|
20 |
-
example_image_url = "https://
|
21 |
example_image_response = requests.get(example_image_url)
|
22 |
example_image = Image.open(BytesIO(example_image_response.content))
|
23 |
|
@@ -34,7 +34,10 @@ if st.button("Generate Image") and text:
|
|
34 |
|
35 |
# For visualization, you can convert the image representation back to an image
|
36 |
image_array = image_representation.squeeze().cpu().numpy()
|
37 |
-
|
38 |
|
39 |
# Display the generated image
|
40 |
-
st.image(
|
|
|
|
|
|
|
|
17 |
text_features = clip_processor(text, return_tensors="pt", padding=True)
|
18 |
|
19 |
# Load an example image from the web (replace this with your image loading logic)
|
20 |
+
example_image_url = "https://source.unsplash.com/random"
|
21 |
example_image_response = requests.get(example_image_url)
|
22 |
example_image = Image.open(BytesIO(example_image_response.content))
|
23 |
|
|
|
34 |
|
35 |
# For visualization, you can convert the image representation back to an image
|
36 |
image_array = image_representation.squeeze().cpu().numpy()
|
37 |
+
generated_image = Image.fromarray((image_array * 255).astype('uint8'))
|
38 |
|
39 |
# Display the generated image
|
40 |
+
st.image(generated_image, caption="Generated Image", use_column_width=True)
|
41 |
+
|
42 |
+
# Save the generated image to a file (change the file path as needed)
|
43 |
+
generated_image.save("generated_image.jpg")
|