Spaces:
Runtime error
Runtime error
Update pages/ImageToText.py
Browse files- pages/ImageToText.py +3 -3
pages/ImageToText.py
CHANGED
@@ -11,7 +11,7 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
11 |
|
12 |
vitgpt_model.to(device)
|
13 |
|
14 |
-
def generate_caption(processor, model, image, tokenizer=None
|
15 |
|
16 |
inputs = processor(images=image, return_tensors="pt").to(device)
|
17 |
generated_ids = model.generate(pixel_values=inputs.pixel_values,
|
@@ -30,7 +30,7 @@ def generate_caption(processor, model, image, tokenizer=None, num_seq):
|
|
30 |
return generated_caption
|
31 |
|
32 |
def generate_captions(image, num_seq):
|
33 |
-
caption_vitgpt = generate_caption(vitgpt_processor, vitgpt_model, image,
|
34 |
return caption_vitgpt
|
35 |
|
36 |
st.title('Generate text to your image')
|
@@ -44,6 +44,6 @@ if uploaded_file is not None:
|
|
44 |
image = Image.open(uploaded_file)
|
45 |
st.image(image)
|
46 |
with col2:
|
47 |
-
generated_caption = generate_caption(vitgpt_processor, vitgpt_model, image, vitgpt_tokenizer)
|
48 |
for i in generated_caption:
|
49 |
st.write(i)
|
|
|
11 |
|
12 |
vitgpt_model.to(device)
|
13 |
|
14 |
+
def generate_caption(processor, model, image, num_seq, tokenizer=None):
|
15 |
|
16 |
inputs = processor(images=image, return_tensors="pt").to(device)
|
17 |
generated_ids = model.generate(pixel_values=inputs.pixel_values,
|
|
|
30 |
return generated_caption
|
31 |
|
32 |
def generate_captions(image, num_seq):
|
33 |
+
caption_vitgpt = generate_caption(vitgpt_processor, vitgpt_model, image, num_seq, vitgpt_tokenizer)
|
34 |
return caption_vitgpt
|
35 |
|
36 |
st.title('Generate text to your image')
|
|
|
44 |
image = Image.open(uploaded_file)
|
45 |
st.image(image)
|
46 |
with col2:
|
47 |
+
generated_caption = generate_caption(vitgpt_processor, vitgpt_model, image, num_seq, vitgpt_tokenizer)
|
48 |
for i in generated_caption:
|
49 |
st.write(i)
|