Tharunika1601 commited on
Commit
414dca8
1 Parent(s): d312027

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -2,6 +2,8 @@ import streamlit as st
2
  from transformers import CLIPProcessor, CLIPModel
3
  import torch
4
  from PIL import Image
 
 
5
 
6
  st.title("Text to Image Generation with CLIP")
7
 
@@ -14,9 +16,10 @@ if st.button("Generate Image") and text:
14
  # Process text and get CLIP features for text
15
  text_features = clip_processor(text, return_tensors="pt", padding=True)
16
 
17
- # Load an example image (replace this with your image loading logic)
18
- example_image_path = "path/to/your/image.jpg"
19
- example_image = Image.open(example_image_path)
 
20
 
21
  # Process image and get CLIP features for image
22
  image_features = clip_processor(images=example_image, return_tensors="pt", padding=True)
 
2
  from transformers import CLIPProcessor, CLIPModel
3
  import torch
4
  from PIL import Image
5
+ import requests
6
+ from io import BytesIO
7
 
8
  st.title("Text to Image Generation with CLIP")
9
 
 
16
  # Process text and get CLIP features for 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://example.com/your-image.jpg"
21
+ example_image_response = requests.get(example_image_url)
22
+ example_image = Image.open(BytesIO(example_image_response.content))
23
 
24
  # Process image and get CLIP features for image
25
  image_features = clip_processor(images=example_image, return_tensors="pt", padding=True)