Ceyda Cinarel commited on
Commit
b82b2c8
1 Parent(s): b10f4fc

add animation

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +4 -0
  2. app.py +13 -5
  3. gif/EV0-Qp8WoAAFheU.gif +0 -0
  4. gif/EV03eYZUwAAJvOw.gif +0 -0
  5. gif/EV03xAhWkAEe_5j.gif +0 -0
  6. gif/EV04ppxVcAEJYDr.gif +0 -0
  7. gif/EV04wElUcAAc-nM.gif +0 -0
  8. gif/EV05UZyWsAIDKFf.gif +0 -0
  9. gif/EV08PG0XYAExhuz.gif +0 -0
  10. gif/EV08uc7XQAIWTHB.gif +0 -0
  11. gif/EV09U7qWkAUGI6H.gif +0 -0
  12. gif/EV0B7R1U8AA-6MQ.gif +0 -0
  13. gif/EV0DceuUYAUW7ro.gif +0 -0
  14. gif/EV0E-WIU0AAunHB.gif +0 -0
  15. gif/EV0ErtAVAAUW4WK.gif +0 -0
  16. gif/EV0GCWUU4AgAtqH.gif +0 -0
  17. gif/EV0Ga4yXQAAj-XB.gif +0 -0
  18. gif/EV0IrdSX0AQ8rlO.gif +0 -0
  19. gif/EV0JpKuU8AAs3PK.gif +0 -0
  20. gif/EV0LAHjXsAEQYPQ.gif +0 -0
  21. gif/EV0MiNTXkAY0jQD.gif +0 -0
  22. gif/EV0MmvmWkAIK2R3.gif +0 -0
  23. gif/EV0NQoFU8AMBKao.gif +0 -0
  24. gif/EV0SOmQWkAEEi5S.gif +0 -0
  25. gif/EV0SayJWoAACWjJ.gif +0 -0
  26. gif/EV0U-giWsAA1JpH.gif +0 -0
  27. gif/EV0UOtDUwAAP0ci.gif +0 -0
  28. gif/EV0V1KoX0AI2xIr.gif +0 -0
  29. gif/EV0VJ7OWkAkylmB.gif +0 -0
  30. gif/EV0YQG5WAAoqvf7.gif +0 -0
  31. gif/EV0Yvw9WkAEw5n8.gif +0 -0
  32. gif/EV0YwksUcAEAVC9.gif +0 -0
  33. gif/EV0_GIFWsAAQlOZ.gif +0 -0
  34. gif/EV0_mQLX0AAWDns.gif +0 -0
  35. gif/EV0_zPYWoAMjkPP.gif +0 -0
  36. gif/EV0a8CxUEAUqhe7.gif +0 -0
  37. gif/EV0cCLNXQAE-CQz.gif +0 -0
  38. gif/EV0cv6oWsAU1ac6.gif +0 -0
  39. gif/EV0ds2gU0AE-5dQ.gif +0 -0
  40. gif/EV0e254WkAAq0i1.gif +0 -0
  41. gif/EV0eJCDWkAkRj54.gif +0 -0
  42. gif/EV0gzd3WAAIIOml.gif +0 -0
  43. gif/EV0iHapWkAUR-A9.gif +0 -0
  44. gif/EV0ibFUXkAIlKL4.gif +0 -0
  45. gif/EV0ifANWoAMVxag.gif +0 -0
  46. gif/EV0jVlWWsAEgaZm.gif +0 -0
  47. gif/EV0liWfWoAUvsvH.gif +0 -0
  48. gif/EV0mP0qUYAA-fb8.gif +0 -0
  49. gif/EV0nZLrU0AATvGq.gif +0 -0
  50. gif/EV0o-9eX0AAq-fv.gif +0 -0
.gitattributes CHANGED
@@ -14,3 +14,7 @@
14
  *.pb filter=lfs diff=lfs merge=lfs -text
15
  *.pt filter=lfs diff=lfs merge=lfs -text
16
  *.pth filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
14
  *.pb filter=lfs diff=lfs merge=lfs -text
15
  *.pt filter=lfs diff=lfs merge=lfs -text
16
  *.pth filter=lfs diff=lfs merge=lfs -text
17
+ gif/EV0ucJyWkAAXPKx.gif filter=lfs diff=lfs merge=lfs -text
18
+ gif/EV1WRb_WoAAFXGj.gif filter=lfs diff=lfs merge=lfs -text
19
+ gif/EVvxHs8XgAA3lhG.gif filter=lfs diff=lfs merge=lfs -text
20
+ gif/EVx4DsWWkAADKOk.gif filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -34,7 +34,7 @@ with st.sidebar.beta_expander("Motivation",expanded=True):
34
  )
35
  top_k=st.sidebar.slider("Show top-K", min_value=1, max_value=50, value=20)
36
  col_count=4
37
- file_names=os.listdir("./imgs")
38
  file_names.sort()
39
 
40
  show_val=st.sidebar.button("show all validation set images")
@@ -42,7 +42,7 @@ if show_val:
42
  cols=st.sidebar.beta_columns(col_count)
43
  for i,im in enumerate(file_names):
44
  j=i%col_count
45
- cols[j].image("./imgs/"+im)
46
 
47
  st.write("# Search Reaction GIFs with CLIP")
48
  st.write(" ")
@@ -82,7 +82,13 @@ def add_image_emb(image):
82
 
83
 
84
  def query_with_images(query_images,query_text):
85
- images = [Image.open(im).convert("RGB") for im in query_images]
 
 
 
 
 
 
86
  inputs = processor(text=[query_text], images=images, return_tensors="jax", padding=True)
87
  inputs["pixel_values"] = jnp.transpose(inputs["pixel_values"], axes=[0, 2, 3, 1])
88
  outputs = model(**inputs)
@@ -109,7 +115,7 @@ q_cols[2].markdown(
109
  )
110
 
111
  query_text = q_cols[0].text_input("Write text you want to get reaction for", value=example_input)
112
- query_images = q_cols[2].file_uploader("(optional) Upload images to rank them",type=['jpg','jpeg'], accept_multiple_files=True)
113
 
114
  if query_images:
115
  st.write("Ranking your uploaded images with respect to input text:")
@@ -120,12 +126,14 @@ else:
120
  vec = np.asarray(model.get_text_features(**proc))
121
  ids, dists = image_index.knnQuery(vec, k=top_k)
122
 
 
 
123
  res_cols=st.beta_columns(col_count)
124
  for i,(id_, dist) in enumerate(zip(ids, dists)):
125
  j=i%col_count
126
  with res_cols[j]:
127
  if isinstance(id_, np.int32):
128
- st.image("./imgs/"+file_names[id_])
129
  # st.write(file_names[id_])
130
  st.write(1.0 - dist, help="score")
131
  else:
 
34
  )
35
  top_k=st.sidebar.slider("Show top-K", min_value=1, max_value=50, value=20)
36
  col_count=4
37
+ file_names=os.listdir("./jpg")
38
  file_names.sort()
39
 
40
  show_val=st.sidebar.button("show all validation set images")
 
42
  cols=st.sidebar.beta_columns(col_count)
43
  for i,im in enumerate(file_names):
44
  j=i%col_count
45
+ cols[j].image("./jpg/"+im)
46
 
47
  st.write("# Search Reaction GIFs with CLIP")
48
  st.write(" ")
 
82
 
83
 
84
  def query_with_images(query_images,query_text):
85
+ images=[]
86
+ for im in query_images:
87
+ img=Image.open(im).convert("RGB")
88
+ if im.name.endswith(".gif"):
89
+ img.seek(0)
90
+ images.append(img)
91
+
92
  inputs = processor(text=[query_text], images=images, return_tensors="jax", padding=True)
93
  inputs["pixel_values"] = jnp.transpose(inputs["pixel_values"], axes=[0, 2, 3, 1])
94
  outputs = model(**inputs)
 
115
  )
116
 
117
  query_text = q_cols[0].text_input("Write text you want to get reaction for", value=example_input)
118
+ query_images = q_cols[2].file_uploader("(optional) Upload images to rank them",type=['jpg','jpeg','gif'], accept_multiple_files=True)
119
 
120
  if query_images:
121
  st.write("Ranking your uploaded images with respect to input text:")
 
126
  vec = np.asarray(model.get_text_features(**proc))
127
  ids, dists = image_index.knnQuery(vec, k=top_k)
128
 
129
+ show_gif=st.checkbox("Play GIFs",value=True,help="Will play the original animation. Only first frame is used in training!")
130
+ ext = "jpg" if not show_gif else "gif"
131
  res_cols=st.beta_columns(col_count)
132
  for i,(id_, dist) in enumerate(zip(ids, dists)):
133
  j=i%col_count
134
  with res_cols[j]:
135
  if isinstance(id_, np.int32):
136
+ st.image(f"./{ext}/{file_names[id_][:-4]}.{ext}")
137
  # st.write(file_names[id_])
138
  st.write(1.0 - dist, help="score")
139
  else:
gif/EV0-Qp8WoAAFheU.gif ADDED
gif/EV03eYZUwAAJvOw.gif ADDED
gif/EV03xAhWkAEe_5j.gif ADDED
gif/EV04ppxVcAEJYDr.gif ADDED
gif/EV04wElUcAAc-nM.gif ADDED
gif/EV05UZyWsAIDKFf.gif ADDED
gif/EV08PG0XYAExhuz.gif ADDED
gif/EV08uc7XQAIWTHB.gif ADDED
gif/EV09U7qWkAUGI6H.gif ADDED
gif/EV0B7R1U8AA-6MQ.gif ADDED
gif/EV0DceuUYAUW7ro.gif ADDED
gif/EV0E-WIU0AAunHB.gif ADDED
gif/EV0ErtAVAAUW4WK.gif ADDED
gif/EV0GCWUU4AgAtqH.gif ADDED
gif/EV0Ga4yXQAAj-XB.gif ADDED
gif/EV0IrdSX0AQ8rlO.gif ADDED
gif/EV0JpKuU8AAs3PK.gif ADDED
gif/EV0LAHjXsAEQYPQ.gif ADDED
gif/EV0MiNTXkAY0jQD.gif ADDED
gif/EV0MmvmWkAIK2R3.gif ADDED
gif/EV0NQoFU8AMBKao.gif ADDED
gif/EV0SOmQWkAEEi5S.gif ADDED
gif/EV0SayJWoAACWjJ.gif ADDED
gif/EV0U-giWsAA1JpH.gif ADDED
gif/EV0UOtDUwAAP0ci.gif ADDED
gif/EV0V1KoX0AI2xIr.gif ADDED
gif/EV0VJ7OWkAkylmB.gif ADDED
gif/EV0YQG5WAAoqvf7.gif ADDED
gif/EV0Yvw9WkAEw5n8.gif ADDED
gif/EV0YwksUcAEAVC9.gif ADDED
gif/EV0_GIFWsAAQlOZ.gif ADDED
gif/EV0_mQLX0AAWDns.gif ADDED
gif/EV0_zPYWoAMjkPP.gif ADDED
gif/EV0a8CxUEAUqhe7.gif ADDED
gif/EV0cCLNXQAE-CQz.gif ADDED
gif/EV0cv6oWsAU1ac6.gif ADDED
gif/EV0ds2gU0AE-5dQ.gif ADDED
gif/EV0e254WkAAq0i1.gif ADDED
gif/EV0eJCDWkAkRj54.gif ADDED
gif/EV0gzd3WAAIIOml.gif ADDED
gif/EV0iHapWkAUR-A9.gif ADDED
gif/EV0ibFUXkAIlKL4.gif ADDED
gif/EV0ifANWoAMVxag.gif ADDED
gif/EV0jVlWWsAEgaZm.gif ADDED
gif/EV0liWfWoAUvsvH.gif ADDED
gif/EV0mP0qUYAA-fb8.gif ADDED
gif/EV0nZLrU0AATvGq.gif ADDED
gif/EV0o-9eX0AAq-fv.gif ADDED