Spaces:
Configuration error
Configuration error
| import gradio as gr | |
| import os | |
| import random | |
| from datetime import datetime | |
| from huggingface_hub import HfApi | |
| API = HfApi() | |
| ASSETS_REPO = "RedSparkie/dreamfactory-assets" | |
| SPACE_REPO = "RedSparkie/dreamfactory" | |
| NICHE_CATALOG = { | |
| "Cyberpunk": "cyberpunk, neon, futuristic, dystopian, sci-fi, night city, rain, holograms, synthwave", | |
| "Fantasy": "fantasy landscape, magical forest, dragons, enchanted, ethereal, mystical, medieval", | |
| "Minimalist Zen": "minimalist, zen, Japanese garden, nature, peaceful, serene, simple, elegant", | |
| "Steampunk": "steampunk, brass gears, mechanical, Victorian, retro-futuristic, clockwork, copper", | |
| "Cosmic/Abstract": "cosmic, abstract, galaxy, nebula, spiritual, surreal, universe, stars, ethereal", | |
| "Kawaii/Merch": "kawaii, cute, chibi, adorable, colorful, cartoon, merchandise-ready, print design", | |
| "Automotive/Luxury": "luxury car, sports car, automotive, chrome, speed, premium, showroom, photorealistic", | |
| } | |
| def generate_marketplace_metadata(meta): | |
| niche = meta.get("niche", "Art") | |
| tags = meta.get("tags", []) | |
| titles = { | |
| "Cyberpunk": f"Neon {random.choice(['Dragon','Cityscape','Warrior','Dream'])} β Premium Digital Art", | |
| "Fantasy": f"Enchanted {random.choice(['Forest','Realm','Waterfall','Garden'])} β Fantasy Art Print", | |
| "Minimalist Zen": f"Zen {random.choice(['Harmony','Balance','Serenity','Moment'])} β Minimalist Art", | |
| "Steampunk": f"Clockwork {random.choice(['Owl','Heart','City','Explorer'])} β Steampunk Digital", | |
| "Cosmic/Abstract": f"Cosmic {random.choice(['Awakening','Journey','Soul','Vision'])} β Abstract Art", | |
| "Kawaii/Merch": f"Cute {random.choice(['Space Cat','Dream','Adventure','Magic'])} β Kawaii Illustration", | |
| "Automotive/Luxury": f"{random.choice(['Chrome','Midnight','Velocity','Elite'])} β Luxury Automotive Art", | |
| } | |
| title = titles.get(niche, "Premium Digital Art β Limited Edition") | |
| description = f"""π¨ {title} | |
| Exclusive AI-generated digital artwork from the DreamFactory collection. | |
| β¨ Features: | |
| β’ Ultra-high resolution ready for printing | |
| β’ Perfect for wall art, posters, and merchandise | |
| β’ Unique piece generated with professional prompts | |
| β’ Digital download β instant delivery | |
| π You will receive: | |
| β’ High-resolution file | |
| β’ License for personal and commercial use (print-on-demand) | |
| π Tags: {', '.join(tags[:8])} | |
| Β© DreamFactory AI Art. | |
| """ | |
| marketplace_tags = tags + ["digital art", "AI art", "printable", "wall art", "poster", "home decor"] | |
| return title, description, marketplace_tags | |
| with gr.Blocks(title="DreamFactory AI Art", theme=gr.themes.Soft()) as demo: | |
| gr.Markdown("""# π DreamFactory AI Art\n### Fully Automated Digital Content Business\n*Zero-touch premium art generation, ready for passive income distribution*""") | |
| with gr.Tab("π¨ Generate New Art"): | |
| with gr.Row(): | |
| niche_dd = gr.Dropdown(choices=list(NICHE_CATALOG.keys()), value="Cyberpunk", label="Art Niche") | |
| count_sl = gr.Slider(1, 4, value=1, step=1, label="Batch Count") | |
| seed_num = gr.Number(value=0, label="Seed (0=random)", precision=0) | |
| gen_btn = gr.Button("β¨ GENERATE ART", variant="primary") | |
| gallery_out = gr.Gallery(label="Generated Artworks", columns=2, height="auto") | |
| meta_json = gr.JSON(label="Generation Metadata") | |
| def gen_and_show(niche, count, seed): | |
| results = [] | |
| for i in range(int(count)): | |
| s = int(seed) if seed > 0 else random.randint(1000, 999999) | |
| base = NICHE_CATALOG.get(niche, niche) | |
| mods = ["masterpiece, ultra detailed, 8k quality, professional","highly detailed, cinematic lighting, award winning art","digital art, trending on artstation, studio quality","hyperdetailed, perfect composition, gallery quality"] | |
| prompt = f"{base}, {random.choice(mods)}" | |
| res_map = {"Cyberpunk":(1344,576),"Fantasy":(1152,864),"Minimalist Zen":(1024,1024),"Steampunk":(1024,1024),"Cosmic/Abstract":(1024,1536),"Kawaii/Merch":(1024,1024),"Automotive/Luxury":(1680,720)} | |
| w,h = res_map.get(niche,(1024,1024)) | |
| try: | |
| from gradio_client import Client | |
| c = Client("mcp-tools/Z-Image-Turbo") | |
| result = c.predict(prompt=prompt, resolution=f"{w}x{h}", steps=12, shift=3, seed=s, api_name="/predict") | |
| meta = {"prompt":prompt,"niche":niche,"seed":s,"resolution":f"{w}x{h}","date":datetime.now().isoformat(),"tags":base.split(", ")} | |
| results.append((result, meta)) | |
| except Exception as e: | |
| results.append((None, {"error":str(e)})) | |
| imgs, metas = [], [] | |
| for img, meta in results: | |
| if img: imgs.append(img); metas.append(meta) | |
| return imgs, metas | |
| gen_btn.click(gen_and_show, inputs=[niche_dd, count_sl, seed_num], outputs=[gallery_out, meta_json]) | |
| with gr.Tab("π¦ Marketplace Export Kit"): | |
| gr.Markdown("""### π Passive Income Workflow\nEvery artwork comes with **pre-formatted metadata** for instant upload to:\n\n1. **Gumroad** β Sell digital downloads\n2. **Etsy** β Sell as digital downloads or POD listings\n3. **Redbubble/Society6** β Auto-sync with print-on-demand products\n4. **Adobe Stock/Shutterstock** β License as stock art\n5. **NFT Marketplaces** β Mint as digital collectibles\n\n**How to automate:** Generate β Export β Bulk upload β Set & forget.""") | |
| meta_input = gr.JSON(label="Paste generation metadata", value={"niche": "Cyberpunk", "tags": ["cyberpunk", "neon", "futuristic", "dystopian", "sci-fi"], "prompt": "cyberpunk dragon, neon, futuristic, masterpiece, ultra detailed"}) | |
| export_btn = gr.Button("π Generate Marketplace Listing") | |
| title_out = gr.Textbox(label="Product Title") | |
| desc_out = gr.Textbox(label="Product Description", lines=10) | |
| tags_out = gr.Textbox(label="Tags (comma-separated)") | |
| def do_export(meta): | |
| t, d, tags = generate_marketplace_metadata(meta) | |
| return t, d, ", ".join(tags) | |
| export_btn.click(do_export, inputs=[meta_input], outputs=[title_out, desc_out, tags_out]) | |
| with gr.Tab("π° Monetization Dashboard"): | |
| gr.Markdown("""### π΅ Revenue Model (Fully Automated)\n\n| Channel | Effort | Est. Monthly Revenue |\n|---------|--------|---------------------|\n| **Gumroad** digital downloads | Upload once | $200β$500 |\n| **Etsy** digital prints | Upload once + auto-delivery | $300β$800 |\n| **Redbubble** POD | Upload once | $100β$400 |\n| **Adobe Stock** royalties | Upload once | $50β$200 |\n| **NFT collections** | Mint once | Variable |\n\n**Total effort after setup: ZERO.**""") | |
| with gr.Tab("π€ Auto-Mode"): | |
| gr.Markdown("""### π 24/7 Content Factory\n\nTo run this business **fully automatically**:\n\n1. **HF Scheduled Jobs** β Generate 10 images/day\n2. **GitHub Actions** β Auto-commit new assets\n3. **Zapier/Make.com** β Auto-post to Gumroad/Etsy\n4. **Social Bots** β Auto-Tweet/Instagram for traffic\n\n**Recommended cron:** `0 */6 * * *` (4 batches/day = 28 artworks/day)\n\n> **Next step:** Say \"activate auto-mode\" and I will write the automation scripts.""") | |
| auto_niche = gr.Dropdown(choices=list(NICHE_CATALOG.keys()), value="Cyberpunk", label="Niche for Auto-Gen") | |
| auto_count = gr.Slider(1, 10, value=5, label="Images per Batch") | |
| activate_btn = gr.Button("π ACTIVATE AUTO-MODE") | |
| gr.Markdown("---\n*Built by π€ Hugging Face Agent | Business: 100% automated digital content monetization*") | |
| if __name__ == "__main__": | |
| demo.launch() | |