Pattira commited on
Commit
8d1ca0b
·
verified ·
1 Parent(s): 12a479b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -9
app.py CHANGED
@@ -40,12 +40,8 @@ Instagram Caption:
40
 
41
  hf_api_key = os.environ["HF_API_KEY"]
42
 
43
- def generate_caption(image_file_path, model_name, user_prompt):
44
  image_to_text = ImageCaptioner(model_name="Salesforce/blip-image-captioning-base")
45
- # รวม prompt หลัก + user input
46
- full_prompt_text = base_prompt
47
- if user_prompt.strip():
48
- full_prompt_text += f"\nMake it themed like: {user_prompt.strip()}"
49
 
50
  prompt_template = [ChatMessage.from_user(full_prompt_text)]
51
  prompt_builder = ChatPromptBuilder(template=prompt_template, required_variables="*")
@@ -75,10 +71,6 @@ with gr.Blocks(theme="soft") as demo:
75
  value="deepseek-ai/DeepSeek-V3.1-Terminus",
76
  label="Choose your model!"
77
  )
78
- # 🆕 ช่องให้ผู้ใช้พิมพ์ธีมของ Caption
79
- user_prompt = gr.Textbox(
80
- label="Add a theme or tone (e.g. romantic, funny, luxury...)",
81
- placeholder="Type here to customize the caption style"
82
 
83
  gr.Examples(["./whale.png", "./rainbow.jpeg", "./selfie.png"], inputs=image, label="Click on any example")
84
  submit_btn = gr.Button("✨ Captionate ✨")
 
40
 
41
  hf_api_key = os.environ["HF_API_KEY"]
42
 
43
+ def generate_caption(image_file_path, model_name):
44
  image_to_text = ImageCaptioner(model_name="Salesforce/blip-image-captioning-base")
 
 
 
 
45
 
46
  prompt_template = [ChatMessage.from_user(full_prompt_text)]
47
  prompt_builder = ChatPromptBuilder(template=prompt_template, required_variables="*")
 
71
  value="deepseek-ai/DeepSeek-V3.1-Terminus",
72
  label="Choose your model!"
73
  )
 
 
 
 
74
 
75
  gr.Examples(["./whale.png", "./rainbow.jpeg", "./selfie.png"], inputs=image, label="Click on any example")
76
  submit_btn = gr.Button("✨ Captionate ✨")