ameerazam08's picture
Update app.py
b02e698 verified
import os
os.system("wget https://huggingface.co/stabilityai/StableWurst/resolve/main/effnet_encoder.safetensors -P models -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 models -q --show-progress ")
os.system("wget https://huggingface.co/stabilityai/StableWurst/resolve/main/stage_a.safetensors -P models -q --show-progress ")
os.system("wget https://huggingface.co/stabilityai/StableWurst/resolve/main/stage_b_bf16.safetensors -P models -q --show-progress")
os.system("wget https://huggingface.co/stabilityai/StableWurst/resolve/main/stage_c_bf16.safetensors -P models -q --show-progress")
os.system("wget https://huggingface.co/stabilityai/stable-cascade/resolve/main/controlnet/super_resolution.safetensors -P models -q --show-progress")
import gradio as gr
from PIL import Image
from main import Upscale_CaseCade
import spaces
import os
import datetime
upscale_class=Upscale_CaseCade()
# scale_fator=7
@spaces.GPU
def scale_image(caption,image_pil,scale_factor):
upscale=upscale_class.upscale_image(caption=caption,image_pil=image_pil.convert("RGB"),scale_fator=scale_factor)
current_date_time = datetime.datetime.now()
print("Current Date and Time:", current_date_time)
return [upscale]
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():
caption = gr.Textbox(label="caption")
image_pil = gr.Image(label="Describe the Image", type='pil')
scale_factor = gr.Slider(minimum=1,maximum=3,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=[caption,image_pil,scale_factor], outputs=[generated_image])
block.queue(max_size=1).launch()
# pip install gradio==4.16.0 gradio_client==0.8.1