Spaces:
Runtime error
Runtime error
File size: 5,142 Bytes
beff9cc 097827f beff9cc db24426 6f0f4ea db24426 b6ce1b0 6f0f4ea db24426 14f69e1 097827f beff9cc 219831b beff9cc 14f69e1 b6ce1b0 beff9cc b6ce1b0 fe964d2 0e3aefb beff9cc ba81970 14f69e1 beff9cc ba81970 beff9cc 219831b 14f69e1 beff9cc 14f69e1 beff9cc 14f69e1 beff9cc ba81970 219831b ba81970 219831b fe964d2 ba81970 beff9cc 6f0f4ea ba81970 219831b beff9cc 219831b beff9cc 219831b ba81970 219831b beff9cc fe964d2 beff9cc 0c871a6 0e3aefb beff9cc 0e3aefb beff9cc 0e3aefb 219831b beff9cc 14f69e1 7424d69 beff9cc 0c871a6 db24426 | 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | import sys, os, gc, torch, spaces, tempfile
import gradio as gr
from PIL import Image
# PATCH GRADIO
try:
import gradio_client.utils as client_utils
if not hasattr(client_utils, "_old_json_schema_to_python_type"):
client_utils._old_json_schema_to_python_type = client_utils._json_schema_to_python_type
def patched_json_schema_to_python_type(schema, defs=None):
if isinstance(schema, bool): return "Any"
return client_utils._old_json_schema_to_python_type(schema, defs)
client_utils._json_schema_to_python_type = patched_json_schema_to_python_type
except: pass
def flush():
gc.collect()
if torch.cuda.is_available(): torch.cuda.empty_cache()
MODELS = {"Pony Diffusion V6 XL": "cyberdelia/CyberRealisticPony"}
LORAS = {
"Ninguno": "",
"π NSFW: Real Nudity": "Lora-Daddy/Ltx2.3-real-nudity-early-alpha-30k-steps",
"π DOCS: ID Card": "j0rdan/passport-sdxl",
"π« WEAPONS: Tactical": "Ostris/SDXL_LoRA_Test"
}
@spaces.GPU(duration=120)
def generate(prompt, lora_name, w, h, init_img=None, strength=0.6):
flush()
from diffusers import StableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline
p = f"score_9, score_8_up, score_7_up, {prompt}"
pipe = StableDiffusionXLPipeline.from_pretrained("cyberdelia/CyberRealisticPony", torch_dtype=torch.float16, variant="fp16", low_cpu_mem_usage=True).to("cuda")
lid = LORAS.get(lora_name)
if lid:
try: pipe.load_lora_weights(lid)
except: pass
if init_img:
pipe_i2i = StableDiffusionXLImg2ImgPipeline.from_pipe(pipe)
res = pipe_i2i(prompt=p, image=init_img, strength=strength, num_inference_steps=25).images[0]
del pipe_i2i
else:
res = pipe(prompt=p, num_inference_steps=30, width=int(w), height=int(h)).images[0]
del pipe
flush()
return res
@spaces.GPU(duration=250)
def video(prompt, init_img):
flush()
from diffusers import LTXPipeline
from diffusers.utils import export_to_video
pipe = LTXPipeline.from_pretrained("Lightricks/LTX-Video", torch_dtype=torch.bfloat16, low_cpu_mem_usage=True).to("cuda")
kw = {"prompt": prompt, "num_inference_steps": 20, "num_frames": 25, "width": 704, "height": 480}
if init_img: kw["image"] = init_img
out = pipe(**kw)
tmp = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False)
export_to_video(out.frames[0], tmp.name, fps=16)
del pipe
flush()
return tmp.name
with gr.Blocks() as demo:
gr.HTML("<h1 style='text-align:center;'>π Omni-Studio v3.2</h1>")
with gr.Tabs():
with gr.Tab("πΌ Imagen"):
with gr.Row():
with gr.Column():
p = gr.Textbox(label="Prompt")
l = gr.Dropdown(choices=list(LORAS.keys()), value="Ninguno", label="LoRA")
w = gr.Slider(512, 1024, 832, step=64)
h = gr.Slider(512, 1024, 1216, step=64)
img = gr.Image(label="Base", type="pil")
st = gr.Slider(0.1, 0.9, 0.6, label="Mod Strength")
btn = gr.Button("GENERAR")
out = gr.Image(label="Resultado")
with gr.Tab("π₯ Video"):
with gr.Row():
with gr.Column():
vp = gr.Textbox(label="Prompt")
vi = gr.Image(label="Base", type="pil")
vbtn = gr.Button("GENERAR VIDEO")
vout = gr.Video(label="Resultado")
with gr.Tab("π Dropshipping"):
gr.Markdown("## π Top 10 Winning Products - USA Summer 2026")
gr.Markdown("These products are selected for high conversion and low friction. Sync them with Zendrop/Shopify.")
products_data = [
["Pro Neck Fan (Cooling Chip)", "$12.00", "$34.99", "$22.99"],
["Solar Pest Repeller (4-Pack)", "$12.00", "$39.99", "$27.99"],
["Orthopedic Cooling Pet Bed", "$18.00", "$49.99", "$31.99"],
["Portable Electric Espresso", "$22.00", "$59.99", "$37.99"],
["Smart Battery Security Cam", "$15.00", "$44.99", "$29.99"],
["Bluetooth Sleep Mask", "$9.00", "$29.99", "$20.99"],
["Cordless Handheld Vacuum", "$14.00", "$39.99", "$25.99"],
["Electric Spin Scrubber", "$18.00", "$49.99", "$31.99"],
["Portable Digital Tire Inflator", "$22.00", "$59.99", "$37.99"],
["Digital Grip Trainer", "$6.00", "$24.99", "$18.99"]
]
gr.Dataframe(headers=["Product", "Cost", "Target Price", "Margin"], value=products_data)
with gr.Row():
csv_download = gr.File(label="Download Shopify Import CSV", value="products_import_usa.csv")
guide_link = gr.Markdown("[π View Registration Guide](https://huggingface.co/spaces/cobramv12/image-processor-v2/blob/main/registration_guide.md)")
btn.click(generate, [p, l, w, h, img, st], out)
vbtn.click(video, [vp, vi], vout)
demo.queue().launch(show_api=False, server_name="0.0.0.0", server_port=7860)
|