Spaces:
Running
Running
File size: 2,346 Bytes
6d601f6 fb8d2a9 17f7d43 fb8d2a9 bb28428 fb8d2a9 0bef8ce bb28428 fb8d2a9 6d601f6 fb8d2a9 a2c4274 aa652b2 fb8d2a9 a60484d fb8d2a9 |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
import streamlit as st
import base64
from huggingface_hub import InferenceClient
client = InferenceClient(api_key=st.secrets["HF_TOKEN"])
def classify_picture(image_url):
messages = [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": image_url
}
},
{
"type": "text",
"text": """Based upon the image, at what sort of location or in where is this participant most likely attending their online meeting? Be more specific rather than general. Answer in one sentence in the format of: "This participant is most likely attending their online meeting [location]."""
},
]
}
]
stream = client.chat.completions.create(
model="meta-llama/Llama-3.2-11B-Vision-Instruct",
messages=messages,
max_tokens=100,
stream=True
)
result = ""
for chunk in stream:
result += chunk.choices[0].delta.content
return result
st.title("Online Meeting Location Classifier")
option = st.selectbox(
"Target Image",
("Camera", "Demo 1", "Demo 2", "Demo 3", "Demo 4"),
index=None,
placeholder="Select Image...",
)
if option == "Camera":
enable = st.checkbox("Enable camera")
picture_buffer = st.camera_input("Take a picture")
if picture_buffer is not None:
image_url = "data:image/jpeg;base64," + base64.b64encode(picture_buffer.getvalue()).decode("utf-8")
if st.button("Generate Location"):
st.write(classify_picture(image_url))
elif option is not None:
if option == "Demo 1":
image_url = "https://media.istockphoto.com/id/1353209475/video/happy-indian-business-man-talking-to-webcam-having-virtual-meeting-in-office.jpg?s=640x640&k=20&c=DUEzmtpErdZxDavYMOmLuKExEWIVWUusRUh9wYd20j0="
elif option == "Demo 2":
image_url = "https://cdn.prod.website-files.com/62180286278929909e43b116/63c216577ab752f188142733_Using%20a%20Custom%20Zoom%20Background.jpg"
elif option == "Demo 3":
image_url = "https://media.istockphoto.com/id/1319103417/photo/inspired-female-teacher-in-headphones-meet-students-online-give-class.jpg?s=612x612&w=0&k=20&c=cSGIQIwPFpVi7m4MR2_SLlwDcpBELdnNnLNgdtH6Bak="
elif option == "Demo 4":
image_url = "https://www.rivertribe.co.uk/wp-content/uploads/2020/04/EV1Twz9XgAExEJ5-e1587484451269.jpg"
st.image(image_url, use_column_width=True)
if st.button("Generate Location"):
st.write(classify_picture(image_url)) |