mdanish commited on
Commit
a5a5f36
·
1 Parent(s): 56a81ca

add full file upload & knn get score functionality

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -76,7 +76,7 @@ def load_knn():
76
 
77
  def main():
78
  st.title("Percept: Human Perception of Street View Image Analyzer")
79
-
80
  try:
81
  with st.spinner('Loading CLIP model... This may take a moment.'):
82
  model, preprocess, tokenizer = load_model()
@@ -96,8 +96,8 @@ def main():
96
  try:
97
  image = Image.open(file)
98
 
99
- st.image(image, caption="Uploaded Image", width=640)
100
-
101
  # Process image
102
  with st.spinner('Processing image...'):
103
  processed_image = process_image(image, preprocess)
@@ -106,7 +106,7 @@ def main():
106
  # Encode into CLIP vector
107
  with torch.no_grad():
108
  vec = model.encode_image(processed_image)
109
-
110
  # Normalize vector
111
  vec /= vec.norm(dim=-1, keepdim=True)
112
  if debug: st.write(vec.shape)
 
76
 
77
  def main():
78
  st.title("Percept: Human Perception of Street View Image Analyzer")
79
+
80
  try:
81
  with st.spinner('Loading CLIP model... This may take a moment.'):
82
  model, preprocess, tokenizer = load_model()
 
96
  try:
97
  image = Image.open(file)
98
 
99
+ st.image(image, caption="Uploaded Image", width=400)
100
+
101
  # Process image
102
  with st.spinner('Processing image...'):
103
  processed_image = process_image(image, preprocess)
 
106
  # Encode into CLIP vector
107
  with torch.no_grad():
108
  vec = model.encode_image(processed_image)
109
+
110
  # Normalize vector
111
  vec /= vec.norm(dim=-1, keepdim=True)
112
  if debug: st.write(vec.shape)