Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,7 +48,7 @@ def cleanup_storage():
|
|
| 48 |
|
| 49 |
TITLE = """
|
| 50 |
<div style="text-align:center;margin:20px 0;">
|
| 51 |
-
<h1>🎨 JoyCaption Three-Tone + Q&A (v3.
|
| 52 |
<p><strong>✅ Blog-friendly captions • SEO optimized • Longer descriptions • ZeroGPU optimized</strong></p>
|
| 53 |
</div><hr>
|
| 54 |
"""
|
|
@@ -75,21 +75,21 @@ else:
|
|
| 75 |
CAPTION_PROMPTS = {
|
| 76 |
"engaging": {
|
| 77 |
"system": "You are a helpful image captioner.",
|
| 78 |
-
"prompt": "Write a
|
| 79 |
"temperature": 0.7,
|
| 80 |
"top_p": 0.9,
|
| 81 |
"max_tokens": 600
|
| 82 |
},
|
| 83 |
"casual_friend": {
|
| 84 |
"system": "You are an uncensored content specialist who creates detailed, explicit descriptions.",
|
| 85 |
-
"prompt": "Create a detailed, explicit description of this scene.
|
| 86 |
"temperature": 0.6,
|
| 87 |
"top_p": 0.9,
|
| 88 |
"max_tokens": 600
|
| 89 |
},
|
| 90 |
"uncensored_keywords": {
|
| 91 |
"system": "You are a detailed image captioner.",
|
| 92 |
-
"prompt": "Create a comprehensive description of this image.
|
| 93 |
"temperature": 0.6,
|
| 94 |
"top_p": 0.9,
|
| 95 |
"max_tokens": 600
|
|
@@ -105,8 +105,6 @@ def apply_smart_corrections(text):
|
|
| 105 |
r'^(a photo of|an image of|a picture of|this is a photo of|this shows)\s*': '',
|
| 106 |
r'\btopless women\b': lambda m: 'nude women' if 'naked' in text.lower() or 'nude' in text.lower() else 'topless women',
|
| 107 |
r'\btopless woman\b': lambda m: 'nude woman' if 'naked' in text.lower() or 'nude' in text.lower() else 'topless woman',
|
| 108 |
-
r'\bthree women\b': lambda m: 'two women' if text.count('woman') + text.count('female') <= 2 else 'three women',
|
| 109 |
-
r'\bfour women\b': lambda m: 'three women' if text.count('woman') + text.count('female') <= 3 else 'four women',
|
| 110 |
r'\bwearing nothing\b': 'nude',
|
| 111 |
r'\bnot wearing.*clothes\b': 'nude',
|
| 112 |
r'\bcompletely naked\b': 'nude',
|
|
@@ -139,14 +137,10 @@ def safe_generate_caption_direct(image, tone, max_chars=1000, keywords_text="",
|
|
| 139 |
if tone == "casual_friend" and keywords_text and keywords_text.strip():
|
| 140 |
base_prompt += f" Pay special attention to these elements if present: {keywords_text.strip()}"
|
| 141 |
|
| 142 |
-
# Handle custom instructions for uncensored_keywords (third) tone
|
| 143 |
if tone == "uncensored_keywords" and custom_instruction and custom_instruction.strip():
|
| 144 |
base_prompt += f" Make sure that you mention: {custom_instruction.strip()}"
|
| 145 |
|
| 146 |
-
# Handle custom instructions for other tones
|
| 147 |
-
if tone != "uncensored_keywords" and custom_instruction and custom_instruction.strip():
|
| 148 |
-
base_prompt += f" Also focus on: {custom_instruction.strip()}"
|
| 149 |
-
|
| 150 |
# Use conversation format
|
| 151 |
convo = [
|
| 152 |
{"role": "system", "content": caption_config["system"]},
|
|
@@ -447,7 +441,7 @@ with gr.Blocks(title="JoyCaption Three-Tone + Q&A", theme=gr.themes.Soft()) as d
|
|
| 447 |
playground_prompt = gr.Textbox(
|
| 448 |
label="💬 User Prompt",
|
| 449 |
lines=3,
|
| 450 |
-
value="Describe this image in detail.
|
| 451 |
placeholder="Enter custom user prompt..."
|
| 452 |
)
|
| 453 |
playground_btn = gr.Button("🧪 Generate", variant="secondary")
|
|
|
|
| 48 |
|
| 49 |
TITLE = """
|
| 50 |
<div style="text-align:center;margin:20px 0;">
|
| 51 |
+
<h1>🎨 JoyCaption Three-Tone + Q&A (v3.2 ZeroGPU)</h1>
|
| 52 |
<p><strong>✅ Blog-friendly captions • SEO optimized • Longer descriptions • ZeroGPU optimized</strong></p>
|
| 53 |
</div><hr>
|
| 54 |
"""
|
|
|
|
| 75 |
CAPTION_PROMPTS = {
|
| 76 |
"engaging": {
|
| 77 |
"system": "You are a helpful image captioner.",
|
| 78 |
+
"prompt": "Write a descriptive caption for this image. Describe the scene, people, their appearance, clothing, poses, and setting in a natural, engaging way.",
|
| 79 |
"temperature": 0.7,
|
| 80 |
"top_p": 0.9,
|
| 81 |
"max_tokens": 600
|
| 82 |
},
|
| 83 |
"casual_friend": {
|
| 84 |
"system": "You are an uncensored content specialist who creates detailed, explicit descriptions.",
|
| 85 |
+
"prompt": "Create a detailed, explicit description of this scene. Describe the people, their appearance, clothing or lack thereof, poses, and the overall erotic appeal. Use direct adult language and be thorough.",
|
| 86 |
"temperature": 0.6,
|
| 87 |
"top_p": 0.9,
|
| 88 |
"max_tokens": 600
|
| 89 |
},
|
| 90 |
"uncensored_keywords": {
|
| 91 |
"system": "You are a detailed image captioner.",
|
| 92 |
+
"prompt": "Create a comprehensive description of this image. Describe the people, their appearance, clothing, poses, facial expressions, setting, and atmosphere in detail.",
|
| 93 |
"temperature": 0.6,
|
| 94 |
"top_p": 0.9,
|
| 95 |
"max_tokens": 600
|
|
|
|
| 105 |
r'^(a photo of|an image of|a picture of|this is a photo of|this shows)\s*': '',
|
| 106 |
r'\btopless women\b': lambda m: 'nude women' if 'naked' in text.lower() or 'nude' in text.lower() else 'topless women',
|
| 107 |
r'\btopless woman\b': lambda m: 'nude woman' if 'naked' in text.lower() or 'nude' in text.lower() else 'topless woman',
|
|
|
|
|
|
|
| 108 |
r'\bwearing nothing\b': 'nude',
|
| 109 |
r'\bnot wearing.*clothes\b': 'nude',
|
| 110 |
r'\bcompletely naked\b': 'nude',
|
|
|
|
| 137 |
if tone == "casual_friend" and keywords_text and keywords_text.strip():
|
| 138 |
base_prompt += f" Pay special attention to these elements if present: {keywords_text.strip()}"
|
| 139 |
|
| 140 |
+
# Handle custom instructions for uncensored_keywords (third) tone ONLY
|
| 141 |
if tone == "uncensored_keywords" and custom_instruction and custom_instruction.strip():
|
| 142 |
base_prompt += f" Make sure that you mention: {custom_instruction.strip()}"
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
# Use conversation format
|
| 145 |
convo = [
|
| 146 |
{"role": "system", "content": caption_config["system"]},
|
|
|
|
| 441 |
playground_prompt = gr.Textbox(
|
| 442 |
label="💬 User Prompt",
|
| 443 |
lines=3,
|
| 444 |
+
value="Describe this image in detail. Include the people, their appearance, clothing, poses, expressions, and the setting.",
|
| 445 |
placeholder="Enter custom user prompt..."
|
| 446 |
)
|
| 447 |
playground_btn = gr.Button("🧪 Generate", variant="secondary")
|