Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ if hf_api_key:
|
|
| 9 |
print(f"API Key Loaded: {hf_api_key}")
|
| 10 |
else:
|
| 11 |
print("API Key not found. Please check your Hugging Face secrets.")
|
| 12 |
-
|
| 13 |
from haystack.components.generators.chat import HuggingFaceAPIChatGenerator
|
| 14 |
from haystack.components.builders.chat_prompt_builder import ChatPromptBuilder
|
| 15 |
from haystack.dataclasses import ChatMessage
|
|
@@ -42,8 +42,6 @@ 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="*")
|
| 48 |
generator = HuggingFaceAPIChatGenerator(
|
| 49 |
api_type="serverless_inference_api",
|
|
@@ -71,7 +69,6 @@ with gr.Blocks(theme="soft") as demo:
|
|
| 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 ✨")
|
| 77 |
caption = gr.Textbox(label="Caption", show_copy_button=True)
|
|
|
|
| 9 |
print(f"API Key Loaded: {hf_api_key}")
|
| 10 |
else:
|
| 11 |
print("API Key not found. Please check your Hugging Face secrets.")
|
| 12 |
+
|
| 13 |
from haystack.components.generators.chat import HuggingFaceAPIChatGenerator
|
| 14 |
from haystack.components.builders.chat_prompt_builder import ChatPromptBuilder
|
| 15 |
from haystack.dataclasses import ChatMessage
|
|
|
|
| 42 |
|
| 43 |
def generate_caption(image_file_path, model_name):
|
| 44 |
image_to_text = ImageCaptioner(model_name="Salesforce/blip-image-captioning-base")
|
|
|
|
|
|
|
| 45 |
prompt_builder = ChatPromptBuilder(template=prompt_template, required_variables="*")
|
| 46 |
generator = HuggingFaceAPIChatGenerator(
|
| 47 |
api_type="serverless_inference_api",
|
|
|
|
| 69 |
value="deepseek-ai/DeepSeek-V3.1-Terminus",
|
| 70 |
label="Choose your model!"
|
| 71 |
)
|
|
|
|
| 72 |
gr.Examples(["./whale.png", "./rainbow.jpeg", "./selfie.png"], inputs=image, label="Click on any example")
|
| 73 |
submit_btn = gr.Button("✨ Captionate ✨")
|
| 74 |
caption = gr.Textbox(label="Caption", show_copy_button=True)
|