Spaces:
Runtime error
Runtime error
fancyfeast commited on
Commit ·
ccb684e
1
Parent(s): 301ae18
Tweak UI
Browse filesFiles changed (2)
- JoyCaptionLogo1.svgAdded
- app.py+23-7
12 unmodified lines13141516171819202122232421 unmodified lines4647484950515253545556571 unmodified line5960616263646597 unmodified lines16316416516616716825 unmodified lines19419519619719819971 unmodified lines27127227327427527627724 unmodified lines30230330430530630730816 unmodified lines32532632732832933012 unmodified linesgap:16px; margin:4px 0 12px;}.joy-header h1{margin:0; font-size:1.9rem; line-height:1.2;}.joy-header p {margin:2px 0 0; font-size:0.9rem; color:#666;}</style><div class="joy-header"><div><h1>JoyCaption <span style="font-weight:400">Beta One</span></h1><p>Image-captioning model | build 2025-05-10a</p></div></div><hr>"""21 unmodified lines<tr><td><strong>Straightforward</strong></td><td>Objective, no fluff, and more succinct than Descriptive.</td></tr><tr><td><strong>Stable Diffusion Prompt</strong></td><td>Reverse-engineers a prompt that could have produced the image in a SD/T2I model.<br><em>⚠︎ Experimental – can glitch ≈ 3 % of the time.</em></td></tr><tr><td><strong>MidJourney</strong></td><td>Same idea as above but tuned to MidJourney’s prompt style.<br><em>⚠︎ Experimental – can glitch ≈ 3 % of the time.</em></td></tr><tr><td><strong>Danbooru tag list</strong></td><td>Comma-separated tags strictly following Danbooru conventions(artist:, copyright:, etc.). Lower-case underscores only.<br><em>⚠︎ Experimental – can glitch ≈ 3 %.</em></td></tr><tr><td><strong>e621 tag list</strong></td><td>Alphabetical, namespaced tags in e621 style – includes species/metatags when relevant.<br><em>⚠︎ Experimental – can glitch ≈ 3 %.</em></td></tr>1 unmodified line<td>Rule34 style alphabetical tag dump; artist/copyright/characterprefixes first.<br><em>⚠︎ Experimental – can glitch ≈ 3 %.</em></td></tr><tr><td><strong>Booru-like tag list</strong></td><td>Looser tag list when you want labels but not a specific Booru format.<br><em>⚠︎ Experimental – can glitch ≈ 3 %.</em></td></tr><tr><td><strong>Art Critic</strong></td><td>Paragraph of art-historical commentary: composition, symbolism, style,lighting, movement, etc.</td></tr>97 unmodified lines"Write a {length} caption for this image as if it were being used for a social media post.",],}25 unmodified lines)@spaces.GPU()@torch.no_grad()def chat_joycaption(input_image: Image.Image, prompt: str, temperature: float, top_p: float, max_new_tokens: int, log_prompt: bool) -> Generator[str, None, None]:71 unmodified lineswith gr.Accordion("Extra Options", open=False):extra_options = gr.CheckboxGroup(choices=["If there is a person/character in the image you must refer to them as {name}.","Do NOT include information about people/characters that cannot be changed (like ethnicity, gender, etc), but do still include changeable attributes (like hair style).","Include information about lighting.","Include information about camera angle.",24 unmodified lineslabel="Select one or more",)name_input = gr.Textbox(label="Person / Character Name")with gr.Accordion("Generation settings", open=False):temperature_slider = gr.Slider(16 unmodified lineswith gr.Column():prompt_box = gr.Textbox(lines=4, label="Prompt", interactive=True)# Auto-update prompt box whenever any of the inputs changefor ctrl in (caption_type, caption_length, extra_options, name_input):ctrl.change(12 unmodified lines131415161718192021222324252621 unmodified lines4849505152535455565758591 unmodified line6162636465666797 unmodified lines16516616716816917017117225 unmodified lines19819920020120220320420520620720871 unmodified lines28028128228328428528624 unmodified lines31131231331431531631716 unmodified lines33433533633733833934034134234334434534612 unmodified linesgap:16px; margin:4px 0 12px;}.joy-header h1{margin:0; font-size:1.9rem; line-height:1.2;}.joy-header p {margin:2px 0 0; font-size:0.9rem; color:#666;}.joy-header img{height:56px;}</style><div class="joy-header"><img src="logo.svg" alt="JoyCaption logo"><div><h1>JoyCaption <span style="font-weight:400">Beta One</span></h1><p>Image-captioning model | build mb3500zp</p></div></div><hr>"""21 unmodified lines<tr><td><strong>Straightforward</strong></td><td>Objective, no fluff, and more succinct than Descriptive.</td></tr><tr><td><strong>Stable Diffusion Prompt</strong></td><td>Reverse-engineers a prompt that could have produced the image in a SD/T2I model.<br><em>⚠︎ Experimental – can glitch ≈ 3% of the time.</em></td></tr><tr><td><strong>MidJourney</strong></td><td>Same idea as above but tuned to MidJourney’s prompt style.<br><em>⚠︎ Experimental – can glitch ≈ 3% of the time.</em></td></tr><tr><td><strong>Danbooru tag list</strong></td><td>Comma-separated tags strictly following Danbooru conventions(artist:, copyright:, etc.). Lower-case underscores only.<br><em>⚠︎ Experimental – can glitch ≈ 3% of the time..</em></td></tr><tr><td><strong>e621 tag list</strong></td><td>Alphabetical, namespaced tags in e621 style – includes species/metatags when relevant.<br><em>⚠︎ Experimental – can glitch ≈ 3 %.</em></td></tr>1 unmodified line<td>Rule34 style alphabetical tag dump; artist/copyright/characterprefixes first.<br><em>⚠︎ Experimental – can glitch ≈ 3 %.</em></td></tr><tr><td><strong>Booru-like tag list</strong></td><td>Looser tag list when you want labels but not a specific Booru format.<br><em>⚠︎ Experimental – can glitch ≈ 3% of the time..</em></td></tr><tr><td><strong>Art Critic</strong></td><td>Paragraph of art-historical commentary: composition, symbolism, style,lighting, movement, etc.</td></tr>97 unmodified lines"Write a {length} caption for this image as if it were being used for a social media post.",],}NAME_OPTION = "If there is a person/character in the image you must refer to them as {name}."25 unmodified lines)def toggle_name_box(selected_options: list[str]):"""Show the name textbox only when the specific option is selected."""return gr.update(visible=NAME_OPTION in selected_options)@spaces.GPU()@torch.no_grad()def chat_joycaption(input_image: Image.Image, prompt: str, temperature: float, top_p: float, max_new_tokens: int, log_prompt: bool) -> Generator[str, None, None]:71 unmodified lineswith gr.Accordion("Extra Options", open=False):extra_options = gr.CheckboxGroup(choices=[NAME_OPTION,"Do NOT include information about people/characters that cannot be changed (like ethnicity, gender, etc), but do still include changeable attributes (like hair style).","Include information about lighting.","Include information about camera angle.",24 unmodified lineslabel="Select one or more",)name_input = gr.Textbox(label="Person / Character Name", visible=False)with gr.Accordion("Generation settings", open=False):temperature_slider = gr.Slider(16 unmodified lineswith gr.Column():prompt_box = gr.Textbox(lines=4, label="Prompt", interactive=True)# Show the name input box only when the specific option is selectedextra_options.change(toggle_name_box,inputs=extra_options,outputs=name_input,)# Auto-update prompt box whenever any of the inputs changefor ctrl in (caption_type, caption_length, extra_options, name_input):ctrl.change(
JoyCaptionLogo1.svgAdded
app.py+23-7