Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
|
|
|
|
|
2 |
import streamlit as st
|
3 |
from PIL import Image
|
4 |
import torch
|
@@ -13,68 +15,6 @@ import yaml
|
|
13 |
# Set Streamlit page configuration for a wide layout
|
14 |
st.set_page_config(layout="wide")
|
15 |
|
16 |
-
# Custom CSS for better layout and mobile responsiveness
|
17 |
-
# st.markdown("""
|
18 |
-
# <style>
|
19 |
-
# .main {
|
20 |
-
# max-width: 1200px; /* Max width for content */
|
21 |
-
# margin: 0 auto;
|
22 |
-
# }
|
23 |
-
# .block-container {
|
24 |
-
# padding-top: 2rem;
|
25 |
-
# padding-bottom: 2rem;
|
26 |
-
# padding-left: 3rem;
|
27 |
-
# padding-right: 3rem;
|
28 |
-
# }
|
29 |
-
# .title {
|
30 |
-
# font-size: 3.2rem;
|
31 |
-
# text-align: center;
|
32 |
-
# background: linear-gradient(135deg, #0575e6 0%, #ff0080 50%, #7928ca 100%);
|
33 |
-
# -webkit-background-clip: text;
|
34 |
-
# -webkit-text-fill-color: transparent;
|
35 |
-
# background-clip: text;
|
36 |
-
# }
|
37 |
-
|
38 |
-
# @keyframes gradientShift {
|
39 |
-
# 0% { background-position: 0% 50%; }
|
40 |
-
# 50% { background-position: 100% 50%; }
|
41 |
-
# 100% { background-position: 0% 50%; }
|
42 |
-
# }
|
43 |
-
# .subheader {
|
44 |
-
# font-size: 1.5rem;
|
45 |
-
# margin-bottom: 20px;
|
46 |
-
# }
|
47 |
-
# .btn {
|
48 |
-
# font-size: 1.1rem;
|
49 |
-
# padding: 10px 20px;
|
50 |
-
# background-color: #FF6347;
|
51 |
-
# color: white;
|
52 |
-
# border-radius: 5px;
|
53 |
-
# border: none;
|
54 |
-
# cursor: pointer;
|
55 |
-
# }
|
56 |
-
# .btn:hover {
|
57 |
-
# background-color: #FF4500;
|
58 |
-
# }
|
59 |
-
# .column-spacing {
|
60 |
-
# display: flex;
|
61 |
-
# justify-content: space-between;
|
62 |
-
# }
|
63 |
-
# .col-half {
|
64 |
-
# width: 48%;
|
65 |
-
# }
|
66 |
-
# .col-full {
|
67 |
-
# width: 100%;
|
68 |
-
# }
|
69 |
-
# .instructions {
|
70 |
-
# padding: 20px;
|
71 |
-
# background-color: #f9f9f9;
|
72 |
-
# border-radius: 8px;
|
73 |
-
# box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
74 |
-
# }
|
75 |
-
# </style>
|
76 |
-
# """, unsafe_allow_html=True)
|
77 |
-
|
78 |
# Custom CSS for better layout and mobile responsiveness
|
79 |
st.markdown("""
|
80 |
<style>
|
@@ -89,9 +29,18 @@ st.markdown("""
|
|
89 |
padding-right: 3rem;
|
90 |
}
|
91 |
.title {
|
92 |
-
font-size:
|
93 |
text-align: center;
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
.subheader {
|
97 |
font-size: 1.5rem;
|
@@ -128,6 +77,59 @@ st.markdown("""
|
|
128 |
</style>
|
129 |
""", unsafe_allow_html=True)
|
130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
# Load Model and Processor
|
132 |
@st.cache_resource
|
133 |
def load_model():
|
@@ -186,8 +188,8 @@ def apply_transform(image, size_mode=512):
|
|
186 |
return transformed["image"]
|
187 |
|
188 |
# Streamlit UI with Colorful Title and Emojis
|
|
|
189 |
# st.markdown("<h1 class='title'>π©Ί Knowledge to Sight: Reasoning over Visual Attributes via Knowledge Decomposition for Abnormality Grounding π</h1>", unsafe_allow_html=True)
|
190 |
-
st.markdown("<h1 class='title'>π©Ί Knowledge to Sight: Reasoning over Visual Attributes via Knowledge Decomposition for Abnormality Grounding π</h1>", unsafe_allow_html=True)
|
191 |
st.markdown(
|
192 |
"<p style='text-align: center; font-size: 18px;'>Welcome to a simple demo of our work! π Choose an example or upload your own image to get started! π</p>",
|
193 |
unsafe_allow_html=True
|
|
|
1 |
|
2 |
+
import os
|
3 |
+
os.environ["HF_HOME"] = "/tmp/hf_cache"
|
4 |
import streamlit as st
|
5 |
from PIL import Image
|
6 |
import torch
|
|
|
15 |
# Set Streamlit page configuration for a wide layout
|
16 |
st.set_page_config(layout="wide")
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# Custom CSS for better layout and mobile responsiveness
|
19 |
st.markdown("""
|
20 |
<style>
|
|
|
29 |
padding-right: 3rem;
|
30 |
}
|
31 |
.title {
|
32 |
+
font-size: 3.2rem;
|
33 |
text-align: center;
|
34 |
+
background: linear-gradient(135deg, #0575e6 0%, #ff0080 50%, #7928ca 100%);
|
35 |
+
-webkit-background-clip: text;
|
36 |
+
-webkit-text-fill-color: transparent;
|
37 |
+
background-clip: text;
|
38 |
+
}
|
39 |
+
|
40 |
+
@keyframes gradientShift {
|
41 |
+
0% { background-position: 0% 50%; }
|
42 |
+
50% { background-position: 100% 50%; }
|
43 |
+
100% { background-position: 0% 50%; }
|
44 |
}
|
45 |
.subheader {
|
46 |
font-size: 1.5rem;
|
|
|
77 |
</style>
|
78 |
""", unsafe_allow_html=True)
|
79 |
|
80 |
+
# # Custom CSS for better layout and mobile responsiveness
|
81 |
+
# st.markdown("""
|
82 |
+
# <style>
|
83 |
+
# .main {
|
84 |
+
# max-width: 1200px; /* Max width for content */
|
85 |
+
# margin: 0 auto;
|
86 |
+
# }
|
87 |
+
# .block-container {
|
88 |
+
# padding-top: 2rem;
|
89 |
+
# padding-bottom: 2rem;
|
90 |
+
# padding-left: 3rem;
|
91 |
+
# padding-right: 3rem;
|
92 |
+
# }
|
93 |
+
# .title {
|
94 |
+
# font-size: 2.5rem;
|
95 |
+
# text-align: center;
|
96 |
+
# color: #FF6347;
|
97 |
+
# }
|
98 |
+
# .subheader {
|
99 |
+
# font-size: 1.5rem;
|
100 |
+
# margin-bottom: 20px;
|
101 |
+
# }
|
102 |
+
# .btn {
|
103 |
+
# font-size: 1.1rem;
|
104 |
+
# padding: 10px 20px;
|
105 |
+
# background-color: #FF6347;
|
106 |
+
# color: white;
|
107 |
+
# border-radius: 5px;
|
108 |
+
# border: none;
|
109 |
+
# cursor: pointer;
|
110 |
+
# }
|
111 |
+
# .btn:hover {
|
112 |
+
# background-color: #FF4500;
|
113 |
+
# }
|
114 |
+
# .column-spacing {
|
115 |
+
# display: flex;
|
116 |
+
# justify-content: space-between;
|
117 |
+
# }
|
118 |
+
# .col-half {
|
119 |
+
# width: 48%;
|
120 |
+
# }
|
121 |
+
# .col-full {
|
122 |
+
# width: 100%;
|
123 |
+
# }
|
124 |
+
# .instructions {
|
125 |
+
# padding: 20px;
|
126 |
+
# background-color: #f9f9f9;
|
127 |
+
# border-radius: 8px;
|
128 |
+
# box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
129 |
+
# }
|
130 |
+
# </style>
|
131 |
+
# """, unsafe_allow_html=True)
|
132 |
+
|
133 |
# Load Model and Processor
|
134 |
@st.cache_resource
|
135 |
def load_model():
|
|
|
188 |
return transformed["image"]
|
189 |
|
190 |
# Streamlit UI with Colorful Title and Emojis
|
191 |
+
st.markdown("<h1 class='title'>Knowledge to Sight: Reasoning over Visual Attributes via Knowledge Decomposition for Abnormality Grounding </h1>", unsafe_allow_html=True)
|
192 |
# st.markdown("<h1 class='title'>π©Ί Knowledge to Sight: Reasoning over Visual Attributes via Knowledge Decomposition for Abnormality Grounding π</h1>", unsafe_allow_html=True)
|
|
|
193 |
st.markdown(
|
194 |
"<p style='text-align: center; font-size: 18px;'>Welcome to a simple demo of our work! π Choose an example or upload your own image to get started! π</p>",
|
195 |
unsafe_allow_html=True
|