Varsha commited on
Commit ·
fd91652
1
Parent(s): 4292092
a lot of UI cleanup
Browse files- .gitignore +2 -1
- app.py +16 -12
.gitignore
CHANGED
|
@@ -3,4 +3,5 @@ __pycache__/
|
|
| 3 |
*.pyc
|
| 4 |
.DS_Store
|
| 5 |
outputs/
|
| 6 |
-
.ipynb_checkpoints/
|
|
|
|
|
|
| 3 |
*.pyc
|
| 4 |
.DS_Store
|
| 5 |
outputs/
|
| 6 |
+
.ipynb_checkpoints/
|
| 7 |
+
samples/samples/
|
app.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
# PATCHWISE — CLEAN RESEARCH UI
|
| 3 |
# REPLACE ENTIRE app.py WITH THIS
|
| 4 |
# =========================================================
|
|
|
|
| 5 |
import os
|
| 6 |
import streamlit as st
|
| 7 |
import torch
|
|
@@ -9,6 +10,9 @@ import torch.nn.functional as F
|
|
| 9 |
from torchvision import transforms
|
| 10 |
from PIL import Image
|
| 11 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
from adavit_model import AdaViTDynamic
|
| 14 |
|
|
@@ -420,10 +424,10 @@ Quick Demo Samples
|
|
| 420 |
sample_cols = st.columns(4)
|
| 421 |
|
| 422 |
sample_paths = {
|
| 423 |
-
"Airplane": "
|
| 424 |
-
"Dog": "
|
| 425 |
-
"Frog": "
|
| 426 |
-
"Ship": "
|
| 427 |
}
|
| 428 |
|
| 429 |
if "selected_sample" not in st.session_state:
|
|
@@ -485,19 +489,19 @@ if uploaded_file or st.session_state.selected_sample:
|
|
| 485 |
""", unsafe_allow_html=True)
|
| 486 |
|
| 487 |
if uploaded_file:
|
|
|
|
| 488 |
image = Image.open(uploaded_file).convert("RGB")
|
| 489 |
-
else:
|
| 490 |
-
image = Image.open(st.session_state.selected_sample).convert("RGB")
|
| 491 |
|
| 492 |
-
|
| 493 |
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
image,
|
| 497 |
-
use_container_width=True
|
| 498 |
)
|
| 499 |
|
| 500 |
-
|
|
|
|
|
|
|
|
|
|
| 501 |
|
| 502 |
with torch.no_grad():
|
| 503 |
|
|
|
|
| 2 |
# PATCHWISE — CLEAN RESEARCH UI
|
| 3 |
# REPLACE ENTIRE app.py WITH THIS
|
| 4 |
# =========================================================
|
| 5 |
+
from io import BytesIO
|
| 6 |
import os
|
| 7 |
import streamlit as st
|
| 8 |
import torch
|
|
|
|
| 10 |
from torchvision import transforms
|
| 11 |
from PIL import Image
|
| 12 |
import numpy as np
|
| 13 |
+
from io import BytesIO
|
| 14 |
+
import requests
|
| 15 |
+
|
| 16 |
|
| 17 |
from adavit_model import AdaViTDynamic
|
| 18 |
|
|
|
|
| 424 |
sample_cols = st.columns(4)
|
| 425 |
|
| 426 |
sample_paths = {
|
| 427 |
+
"Airplane": "https://images.unsplash.com/photo-1436491865332-7a61a109cc05",
|
| 428 |
+
"Dog": "https://images.unsplash.com/photo-1517849845537-4d257902454a",
|
| 429 |
+
"Frog": "https://images.unsplash.com/photo-1552728089-57bdde30beb3",
|
| 430 |
+
"Ship": "https://images.unsplash.com/photo-1500375592092-40eb2168fd21"
|
| 431 |
}
|
| 432 |
|
| 433 |
if "selected_sample" not in st.session_state:
|
|
|
|
| 489 |
""", unsafe_allow_html=True)
|
| 490 |
|
| 491 |
if uploaded_file:
|
| 492 |
+
|
| 493 |
image = Image.open(uploaded_file).convert("RGB")
|
|
|
|
|
|
|
| 494 |
|
| 495 |
+
else:
|
| 496 |
|
| 497 |
+
response = requests.get(
|
| 498 |
+
st.session_state.selected_sample
|
|
|
|
|
|
|
| 499 |
)
|
| 500 |
|
| 501 |
+
image = Image.open(
|
| 502 |
+
BytesIO(response.content)
|
| 503 |
+
).convert("RGB")
|
| 504 |
+
tensor = transform(image).unsqueeze(0)
|
| 505 |
|
| 506 |
with torch.no_grad():
|
| 507 |
|