Spaces:
Sleeping
Sleeping
Download src/process_images.py from Slep/CondViT-LRVSF-Demo: direct link, hf CLI and curl.
- Browser
- Download file 382 Bytes
-
https://huggingface.co/spaces/Slep/CondViT-LRVSF-Demo/resolve/main/src/process_images.py
- Command line
-
hf download hf://spaces/Slep/CondViT-LRVSF-Demo/src/process_images.py
-
curl -L -o process_images.py https://huggingface.co/spaces/Slep/CondViT-LRVSF-Demo/resolve/main/src/process_images.py
382 Bytes
| from PIL import Image | |
| from io import BytesIO | |
| import base64 | |
| # Index to PIL | |
| def process_img(idx, ds): | |
| img = Image.open(BytesIO(ds.iloc[idx].jpg)).convert("RGB") | |
| return img | |
| def make_img_html(img): | |
| b = BytesIO() | |
| img.save(b, format='PNG') | |
| buffer = b.getvalue() | |
| return f'<img height=200px src="data:image/png;base64,{base64.b64encode(buffer).decode()}"></img>' |