# import os | |
# os.chdir('./models') | |
# os.system("wget https://huggingface.co/stabilityai/StableWurst/resolve/main/effnet_encoder.safetensors -P . -q --show-progress") | |
# os.system("wget https://huggingface.co/stabilityai/stable-cascade/resolve/main/controlnet/inpainting.safetensors -P models -q --show-progress") | |
# os.system("wget https://huggingface.co/stabilityai/StableWurst/resolve/main/previewer.safetensors -P . -q --show-progress") | |
# os.system("wget https://huggingface.co/stabilityai/StableWurst/resolve/main/stage_a.safetensors -P . -q --show-progress") | |
# os.system("wget https://huggingface.co/stabilityai/StableWurst/resolve/main/stage_b_bf16.safetensors -P . -q --show-progress") | |
# os.system("wget https://huggingface.co/stabilityai/StableWurst/resolve/main/stage_c_bf16.safetensors -P . -q --show-progress") | |
# os.system("wget https://huggingface.co/stabilityai/stable-cascade/resolve/main/controlnet/super_resolution.safetensors -P models -q --show-progress") | |
# os.chdir('..') | |
import gradio as gr | |
from PIL import Image | |
from main import Upscale_CaseCade | |
import spaces | |
import os | |
upscale_class=Upscale_CaseCade() | |
# scale_fator=7 | |
# url = "https://cdn.discordapp.com/attachments/1121232062708457508/1205110687538479145/A_photograph_of_a_sunflower_with_sunglasses_on_in__3.jpg?ex=65d72dc9&is=65c4b8c9&hm=72172e774ce6cda618503b3778b844de05cd1208b61e185d8418db512fb2858a&" | |
# image_pil=Image.open("/home/rnd/Documents/Ameer/StableCascade/poster.png").convert("RGB") | |
def scale_image(image_pil,scale_factor): | |
og,ups=upscale_class.upscale_image(image_pil=image_pil.convert("RGB"),scale_fator=scale_factor) | |
return [ups] | |
DESCRIPTION = "# Stable Cascade -> Super Resolution" | |
DESCRIPTION += "\n<p style=\"text-align: center\">Unofficial demo for Cascade-Super Resolution <a href='https://huggingface.co/stabilityai/stable-cascade' target='_blank'>Stable Upscale Cascade</a>, a new high resolution image-to-image model by Stability AI, - <a href='https://huggingface.co/stabilityai/stable-cascade/blob/main/LICENSE' target='_blank'>non-commercial research license</a></p>" | |
# block = gr.Blocks(css="footer {visibility: hidden}", theme='freddyaboulton/dracula_revamped').queue() | |
block = gr.Blocks(css="footer {visibility: hidden}", theme='freddyaboulton/dark').queue() | |
with block: | |
with gr.Row(): | |
gr.Markdown(DESCRIPTION) | |
with gr.Tabs(): | |
with gr.Row(): | |
with gr.Column(): | |
image_pil = gr.Image(label="Describe the Image", type='pil') | |
scale_factor = gr.Slider(minimum=1,maximum=10,value=1, step=1, label="Scale Factor") | |
generate_button = gr.Button("Upscale Image") | |
with gr.Column(): | |
generated_image = gr.Gallery(label="Generated Image",) | |
generate_button.click(fn=scale_image, inputs=[image_pil,scale_factor], outputs=[generated_image]) | |
block.launch(show_api=False, server_port=8888, share=False, show_error=True, max_threads=1) | |
# pip install gradio==4.16.0 gradio_client==0.8.1 |