Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -46,18 +46,22 @@ def process_image(image, preprocess):
|
|
| 46 |
processed_image = preprocess(image).unsqueeze(0)
|
| 47 |
return processed_image
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
def main():
|
| 50 |
st.title("Percept Human Perception Analyzer")
|
| 51 |
-
|
| 52 |
try:
|
| 53 |
-
|
| 54 |
-
with st.spinner('Loading model... This may take a moment.'):
|
| 55 |
model, preprocess, tokenizer = load_model()
|
| 56 |
except Exception as e:
|
| 57 |
st.error(f"Error loading model: {str(e)}")
|
| 58 |
st.info("Please make sure you have enough memory and the correct dependencies installed.")
|
| 59 |
|
| 60 |
-
|
|
|
|
| 61 |
st.write(knn['walkability_vecs'].shape)
|
| 62 |
|
| 63 |
file = st.file_uploader('Upload An Image')
|
|
|
|
| 46 |
processed_image = preprocess(image).unsqueeze(0)
|
| 47 |
return processed_image
|
| 48 |
|
| 49 |
+
@st.cache_resource
|
| 50 |
+
def load_knn():
|
| 51 |
+
return np.load(knnpath)
|
| 52 |
+
|
| 53 |
def main():
|
| 54 |
st.title("Percept Human Perception Analyzer")
|
| 55 |
+
|
| 56 |
try:
|
| 57 |
+
with st.spinner('Loading CLIP model... This may take a moment.'):
|
|
|
|
| 58 |
model, preprocess, tokenizer = load_model()
|
| 59 |
except Exception as e:
|
| 60 |
st.error(f"Error loading model: {str(e)}")
|
| 61 |
st.info("Please make sure you have enough memory and the correct dependencies installed.")
|
| 62 |
|
| 63 |
+
with st.spinner('Loading KNN model... This may take a moment.'):
|
| 64 |
+
knn = load_knn()
|
| 65 |
st.write(knn['walkability_vecs'].shape)
|
| 66 |
|
| 67 |
file = st.file_uploader('Upload An Image')
|