Spaces:
Build error
Build error
feature: allow user to specify num rows, cols in grid
Browse files- most_relevant_part.py +10 -4
most_relevant_part.py
CHANGED
|
@@ -41,9 +41,13 @@ def app(model_name):
|
|
| 41 |
"""
|
| 42 |
Given a piece of text, the CLIP model finds the part of an image that best explains the text.
|
| 43 |
To try it out, you can
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
"""
|
| 48 |
)
|
| 49 |
|
|
@@ -56,6 +60,8 @@ def app(model_name):
|
|
| 56 |
"Enter query to find most relevant part of image ",
|
| 57 |
value="이건 서울의 경복궁 사진이다.",
|
| 58 |
)
|
|
|
|
|
|
|
| 59 |
|
| 60 |
if st.button("질문 (Query)"):
|
| 61 |
if not any([query1, query2]):
|
|
@@ -67,7 +73,7 @@ def app(model_name):
|
|
| 67 |
image = Image.open(image_data)
|
| 68 |
st.image(image)
|
| 69 |
|
| 70 |
-
images = split_image(image)
|
| 71 |
|
| 72 |
inputs = processor(
|
| 73 |
text=captions, images=images, return_tensors="jax", padding=True
|
|
|
|
| 41 |
"""
|
| 42 |
Given a piece of text, the CLIP model finds the part of an image that best explains the text.
|
| 43 |
To try it out, you can
|
| 44 |
+
|
| 45 |
+
1. Upload an image
|
| 46 |
+
2. Explain a part of the image in text
|
| 47 |
+
|
| 48 |
+
which will yield the most relevant image tile from a grid of the image. You can specify how
|
| 49 |
+
granular you want to be with your search by specifying the number of rows and columns that
|
| 50 |
+
make up the image grid.
|
| 51 |
"""
|
| 52 |
)
|
| 53 |
|
|
|
|
| 60 |
"Enter query to find most relevant part of image ",
|
| 61 |
value="이건 서울의 경복궁 사진이다.",
|
| 62 |
)
|
| 63 |
+
num_rows = st.slider("Number of rows", min_value=1, max_value=5, value=3, step=1)
|
| 64 |
+
num_cols = st.slider("Number of columns", min_value=1, max_value=5, value=3, step=1)
|
| 65 |
|
| 66 |
if st.button("질문 (Query)"):
|
| 67 |
if not any([query1, query2]):
|
|
|
|
| 73 |
image = Image.open(image_data)
|
| 74 |
st.image(image)
|
| 75 |
|
| 76 |
+
images = split_image(image, num_rows, num_cols)
|
| 77 |
|
| 78 |
inputs = processor(
|
| 79 |
text=captions, images=images, return_tensors="jax", padding=True
|