-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
44 lines (31 loc) 路 1.14 KB
/
Copy pathapp.py
File metadata and controls
44 lines (31 loc) 路 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
import os
# Fix paths (important for Streamlit Cloud)
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BASE_DIR)
sys.path.append(os.path.join(BASE_DIR, "model ")) # 鈿狅笍 space wala folder
sys.path.append(os.path.join(BASE_DIR, "utils"))
import streamlit as st
from PIL import Image
# Direct imports (no model. / utils.)
from blip import get_caption
from llm import ask_llama
from prompt import build_prompt
st.set_page_config(page_title="Multimodal AI Agent")
st.title("馃 Multimodal AI Agent")
st.write("Upload an image and ask a question")
text = st.text_input("Enter your question:")
image = st.file_uploader("Upload Image", type=["jpg", "png", "jpeg"])
if st.button("Analyze"):
if text and image:
img = Image.open(image)
with st.spinner("Processing..."):
caption = get_caption(img)
prompt = build_prompt(text, caption)
response = ask_llama(prompt)
st.subheader("馃摳 Image Caption:")
st.write(caption)
st.subheader("馃挰 AI Response:")
st.write(response)
else:
st.warning("Please provide both text and image!")