File size: 2,805 Bytes
6a850d5 19adbdc 6a850d5 0bf5991 87f32d6 6a6edcb 65b8d75 87f32d6 65b8d75 6a6edcb 65b8d75 6a6edcb b02e698 6a6edcb 65b8d75 6a6edcb 4625122 6a6edcb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
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 |