Upload folder using huggingface_hub
Browse files- .huggingface.yaml +3 -0
- app.py +41 -0
- requirements.txt +2 -0
.huggingface.yaml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
sdk: gradio
|
| 2 |
+
python_version: 3.12
|
| 3 |
+
hardware: cpu-basic
|
app.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gradio_client import Client, handle_file
|
| 3 |
+
|
| 4 |
+
PROMT_GET_STYLE = 'Describe the artistic style and technique of this image in one sentence, DO NOT DESCRIBE THE PLOT. Start with: "Change the style of this picture to"'
|
| 5 |
+
|
| 6 |
+
def get_joy_caption(
|
| 7 |
+
image_path: str,
|
| 8 |
+
prompt: str = PROMT_GET_STYLE,
|
| 9 |
+
temperature: float = 0.6,
|
| 10 |
+
top_p: float = 0.9,
|
| 11 |
+
max_new_tokens: int = 512,
|
| 12 |
+
log_prompt: bool = True
|
| 13 |
+
) -> str:
|
| 14 |
+
client = Client("fancyfeast/joy-caption-beta-one")
|
| 15 |
+
result = client.predict(
|
| 16 |
+
input_image=handle_file(image_path),
|
| 17 |
+
prompt=prompt,
|
| 18 |
+
temperature=temperature,
|
| 19 |
+
top_p=top_p,
|
| 20 |
+
max_new_tokens=max_new_tokens,
|
| 21 |
+
log_prompt=log_prompt,
|
| 22 |
+
api_name="/chat_joycaption"
|
| 23 |
+
)
|
| 24 |
+
return result
|
| 25 |
+
|
| 26 |
+
with gr.Blocks() as demo:
|
| 27 |
+
gr.Markdown("## Flux Kontext Prompt Generator — Style Transfer")
|
| 28 |
+
|
| 29 |
+
with gr.Row():
|
| 30 |
+
image = gr.Image(type="filepath", label="Upload or Paste Image")
|
| 31 |
+
prompt_out = gr.Textbox(label="Generated Prompt", lines=2)
|
| 32 |
+
|
| 33 |
+
with gr.Row():
|
| 34 |
+
btn = gr.Button("Get Style")
|
| 35 |
+
copy_btn = gr.Button("📋 Copy to Clipboard")
|
| 36 |
+
|
| 37 |
+
btn.click(fn=get_joy_caption, inputs=image, outputs=prompt_out)
|
| 38 |
+
"() => navigator.clipboard.writeText(document.getElementById('prompt_out').value)"
|
| 39 |
+
|
| 40 |
+
if __name__ == "__main__":
|
| 41 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
gradio_client
|