Spaces:
Running
Running
| import gradio as gr | |
| from huggingface_hub import InferenceClient | |
| import os | |
| client = InferenceClient(token=os.getenv("HF_TOKEN")) | |
| def optimize( | |
| image_prompt: str, alt_image_prompt: str, video_prompt: str, | |
| caption: str, kink_theme: str, platform: str, intensity: str | |
| ): | |
| system = f"""You are a viral NSFW content strategist. Optimize ALL inputs for MAX views, FYP algorithm push, and monetization on {platform}. | |
| Rules: Add strong hooks, emojis, questions, CTAs, taboo language, gooner bait. Keep {kink_theme} intensity at {intensity} level. | |
| Return ONLY the 4 optimized strings in JSON.""" | |
| prompt = f"Originals:\nImage: {image_prompt}\nAlt: {alt_image_prompt}\nVideo: {video_prompt}\nCaption: {caption}" | |
| response = client.chat.completions.create( | |
| model="HauhauCS/Qwen3.5-9B-Uncensored-HauhauCS-Aggressive", | |
| messages=[{"role": "system", "content": system}, {"role": "user", "content": prompt}], | |
| max_tokens=1024, | |
| temperature=0.85 | |
| ) | |
| # Parse JSON from response (add robust parsing in production) | |
| optimized = json.loads(response.choices[0].message.content) | |
| return optimized["image"], optimized["alt"], optimized["video"], optimized["caption"] | |
| with gr.Blocks(title="π₯ NSFW Prompt Optimizer") as demo: | |
| gr.Markdown("# AI Prompt Optimizer for Max Viral + Monetization") | |
| with gr.Row(): | |
| image_in = gr.Textbox(label="Image Prompt", lines=3) | |
| alt_in = gr.Textbox(label="Alt Image Prompt", lines=3) | |
| video_in = gr.Textbox(label="Video Prompt", lines=2) | |
| caption_in = gr.Textbox(label="Original Caption", lines=4) | |
| kink = gr.Textbox(label="Kink Theme") | |
| plat = gr.Dropdown(["Twitter/X (NSFW)", "TikTok (Viral NSFW)"], label="Platform") | |
| inten = gr.Radio(["Teasing", "Explicit", "Extreme"], label="Intensity") | |
| optimize_btn = gr.Button("π Optimize for VIRAL + $", variant="primary") | |
| outputs = [gr.Textbox(label=f"Optimized {n}") for n in ["Image", "Alt", "Video", "Caption"]] | |
| optimize_btn.click(optimize, inputs=[image_in, alt_in, video_in, caption_in, kink, plat, inten], outputs=outputs) | |
| demo.launch() |