Spaces:
Runtime error
Runtime error
Commit
·
3bbf214
1
Parent(s):
c24d39e
Auto deploy
Browse files- stCompressService.py +16 -16
stCompressService.py
CHANGED
@@ -89,7 +89,7 @@ def main(debug: bool, quiet: bool, qp: int, disable_gpu: bool):
|
|
89 |
</p>
|
90 |
|
91 |
|
92 |
-
<
|
93 |
|
94 |
> Due to resources limitation, I only provide compression service with model `qp = 3`.
|
95 |
|
@@ -102,22 +102,22 @@ def main(debug: bool, quiet: bool, qp: int, disable_gpu: bool):
|
|
102 |
<br/>
|
103 |
|
104 |
<a href="https://github.com/xiaosu-zhu/McQuic">
|
105 |
-
<
|
106 |
-
<
|
107 |
</a>
|
108 |
|
109 |
""", unsafe_allow_html=True)
|
110 |
|
111 |
if HF_SPACE:
|
112 |
st.markdown("""
|
113 |
-
<
|
114 |
|
115 |
> Due to resources limitation of HF spaces, the upload image size is restricted to lower than `3000 x 3000`.
|
116 |
|
117 |
-
<
|
118 |
|
119 |
> Also, this demo running on HF space is GPU-disabled. So it may be slow.
|
120 |
-
""")
|
121 |
with st.form("SubmitForm"):
|
122 |
uploadedFile = st.file_uploader("Try running McQuic to compress or restore images!", type=["png", "jpg", "jpeg", "mcq"], help="Upload your image or compressed `.mcq` file here.")
|
123 |
cropping = st.checkbox("Cropping image to align grids.", help="If checked, the image is cropped to align feature map grids. This will make compressed file smaller.")
|
@@ -138,18 +138,18 @@ def main(debug: bool, quiet: bool, qp: int, disable_gpu: bool):
|
|
138 |
a = Image.open(uploadedFile)
|
139 |
except PIL.UnidentifiedImageError:
|
140 |
st.markdown("""
|
141 |
-
<
|
142 |
|
143 |
> Image open failed. Please try other images.
|
144 |
-
""")
|
145 |
return
|
146 |
w, h = a.size
|
147 |
if HF_SPACE and (h > 3000 or w > 3000):
|
148 |
st.markdown("""
|
149 |
-
<
|
150 |
|
151 |
> Image is too large. Please try other images.
|
152 |
-
""")
|
153 |
return
|
154 |
raw = torch.ByteTensor(torch.ByteStorage.from_buffer(uploadedFile.read())) # type: ignore
|
155 |
image = decode_image(raw, ImageReadMode.RGB).to(device)
|
@@ -170,19 +170,19 @@ def main(debug: bool, quiet: bool, qp: int, disable_gpu: bool):
|
|
170 |
|
171 |
<p align="center">
|
172 |
<a href="https://www.python.org/" target="_blank">
|
173 |
-
<
|
174 |
</a>
|
175 |
<a href="https://pytorch.org/" target="_blank">
|
176 |
-
<
|
177 |
</a>
|
178 |
<a href="https://github.com/xiaosu-zhu/McQuic/stargazers" target="_blank">
|
179 |
-
<
|
180 |
</a>
|
181 |
<a href="https://github.com/xiaosu-zhu/McQuic/network/members" target="_blank">
|
182 |
-
<
|
183 |
</a>
|
184 |
<a href="https://github.com/xiaosu-zhu/McQuic/blob/main/LICENSE" target="_blank">
|
185 |
-
<
|
186 |
</a>
|
187 |
</p>
|
188 |
|
@@ -192,7 +192,7 @@ def main(debug: bool, quiet: bool, qp: int, disable_gpu: bool):
|
|
192 |
|
193 |
<p align="center"><a href="localhost" target="_blank">CVF Open Access</a> | <a href="localhost" target="_blank">arXiv</a> | <a href="https://github.com/xiaosu-zhu/McQuic#citation" target="_blank">BibTex</a> | <a href="https://huggingface.co/spaces/xiaosu-zhu/McQuic">Demo</a></p>
|
194 |
|
195 |
-
""")
|
196 |
|
197 |
if __name__ == "__main__":
|
198 |
with torch.inference_mode():
|
|
|
89 |
</p>
|
90 |
|
91 |
|
92 |
+
<img src="https://img.shields.io/badge/NOTE-yellow?style=for-the-badge" alt="NOTE"/>
|
93 |
|
94 |
> Due to resources limitation, I only provide compression service with model `qp = 3`.
|
95 |
|
|
|
102 |
<br/>
|
103 |
|
104 |
<a href="https://github.com/xiaosu-zhu/McQuic">
|
105 |
+
<img src="https://raw.githubusercontent.com/xiaosu-zhu/McQuic/main/assets/GitHub-Mark-120px-plus.png" alt="Github"/>
|
106 |
+
<img src="https://img.shields.io/github/stars/xiaosu-zhu/McQuic?style=social" alt="Github"/>
|
107 |
</a>
|
108 |
|
109 |
""", unsafe_allow_html=True)
|
110 |
|
111 |
if HF_SPACE:
|
112 |
st.markdown("""
|
113 |
+
<img src="https://img.shields.io/badge/NOTE-yellow?style=for-the-badge" alt="NOTE"/>
|
114 |
|
115 |
> Due to resources limitation of HF spaces, the upload image size is restricted to lower than `3000 x 3000`.
|
116 |
|
117 |
+
<img src="https://img.shields.io/badge/NOTE-yellow?style=for-the-badge" alt="NOTE"/>
|
118 |
|
119 |
> Also, this demo running on HF space is GPU-disabled. So it may be slow.
|
120 |
+
""", unsafe_allow_html=True)
|
121 |
with st.form("SubmitForm"):
|
122 |
uploadedFile = st.file_uploader("Try running McQuic to compress or restore images!", type=["png", "jpg", "jpeg", "mcq"], help="Upload your image or compressed `.mcq` file here.")
|
123 |
cropping = st.checkbox("Cropping image to align grids.", help="If checked, the image is cropped to align feature map grids. This will make compressed file smaller.")
|
|
|
138 |
a = Image.open(uploadedFile)
|
139 |
except PIL.UnidentifiedImageError:
|
140 |
st.markdown("""
|
141 |
+
<img src="https://img.shields.io/badge/ERROR-red?style=for-the-badge" alt="ERROR"/>
|
142 |
|
143 |
> Image open failed. Please try other images.
|
144 |
+
""", unsafe_allow_html=True)
|
145 |
return
|
146 |
w, h = a.size
|
147 |
if HF_SPACE and (h > 3000 or w > 3000):
|
148 |
st.markdown("""
|
149 |
+
<img src="https://img.shields.io/badge/ERROR-red?style=for-the-badge" alt="ERROR"/>
|
150 |
|
151 |
> Image is too large. Please try other images.
|
152 |
+
""", unsafe_allow_html=True)
|
153 |
return
|
154 |
raw = torch.ByteTensor(torch.ByteStorage.from_buffer(uploadedFile.read())) # type: ignore
|
155 |
image = decode_image(raw, ImageReadMode.RGB).to(device)
|
|
|
170 |
|
171 |
<p align="center">
|
172 |
<a href="https://www.python.org/" target="_blank">
|
173 |
+
<img src="https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54" alt="Python"/>
|
174 |
</a>
|
175 |
<a href="https://pytorch.org/" target="_blank">
|
176 |
+
<img src="https://img.shields.io/badge/PyTorch-%23EE4C2C.svg?style=for-the-badge&logo=PyTorch&logoColor=white" alt="PyTorch"/>
|
177 |
</a>
|
178 |
<a href="https://github.com/xiaosu-zhu/McQuic/stargazers" target="_blank">
|
179 |
+
<img src="https://img.shields.io/github/stars/xiaosu-zhu/McQuic?logo=github&style=for-the-badge" alt="Github stars"/>
|
180 |
</a>
|
181 |
<a href="https://github.com/xiaosu-zhu/McQuic/network/members" target="_blank">
|
182 |
+
<img src="https://img.shields.io/github/forks/xiaosu-zhu/McQuic?logo=github&style=for-the-badge" alt="Github forks"/>
|
183 |
</a>
|
184 |
<a href="https://github.com/xiaosu-zhu/McQuic/blob/main/LICENSE" target="_blank">
|
185 |
+
<img src="https://img.shields.io/github/license/xiaosu-zhu/McQuic?logo=github&style=for-the-badge" alt="Github license"/>
|
186 |
</a>
|
187 |
</p>
|
188 |
|
|
|
192 |
|
193 |
<p align="center"><a href="localhost" target="_blank">CVF Open Access</a> | <a href="localhost" target="_blank">arXiv</a> | <a href="https://github.com/xiaosu-zhu/McQuic#citation" target="_blank">BibTex</a> | <a href="https://huggingface.co/spaces/xiaosu-zhu/McQuic">Demo</a></p>
|
194 |
|
195 |
+
""", unsafe_allow_html=True)
|
196 |
|
197 |
if __name__ == "__main__":
|
198 |
with torch.inference_mode():
|