Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import torch.nn as nn
|
|
8 |
from transformers import Blip2Processor, Blip2ForConditionalGeneration, InstructBlipProcessor, InstructBlipForConditionalGeneration
|
9 |
from my_model.object_detection import detect_and_draw_objects
|
10 |
from my_model.captioner.image_captioning import get_caption
|
|
|
11 |
|
12 |
|
13 |
|
@@ -38,11 +39,13 @@ image = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"])
|
|
38 |
question = st.text_input("Enter your question about the image:")
|
39 |
|
40 |
if st.button('Generate Caption'):
|
|
|
41 |
if image is not None:
|
42 |
# Display the image
|
43 |
st.image(image, use_column_width=True)
|
44 |
caption = get_caption(image)
|
45 |
st.write(caption)
|
|
|
46 |
|
47 |
else:
|
48 |
st.write("Please upload an image and enter a question.")
|
|
|
8 |
from transformers import Blip2Processor, Blip2ForConditionalGeneration, InstructBlipProcessor, InstructBlipForConditionalGeneration
|
9 |
from my_model.object_detection import detect_and_draw_objects
|
10 |
from my_model.captioner.image_captioning import get_caption
|
11 |
+
from my_model.utilities import free_gpu_resources
|
12 |
|
13 |
|
14 |
|
|
|
39 |
question = st.text_input("Enter your question about the image:")
|
40 |
|
41 |
if st.button('Generate Caption'):
|
42 |
+
free_gpu_resources()
|
43 |
if image is not None:
|
44 |
# Display the image
|
45 |
st.image(image, use_column_width=True)
|
46 |
caption = get_caption(image)
|
47 |
st.write(caption)
|
48 |
+
free_gpu_resources()
|
49 |
|
50 |
else:
|
51 |
st.write("Please upload an image and enter a question.")
|