Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,12 +27,20 @@ if show_details:
|
|
27 |
additional_details = st.text_area("Add any additional details or context about the image here:")
|
28 |
|
29 |
# Button to trigger the analysis
|
30 |
-
analyze_button = st.button("Analyse the
|
31 |
|
32 |
if uploaded_file and openai.api_key and analyze_button:
|
33 |
-
with st.spinner("
|
34 |
base64_image = encode_image(uploaded_file)
|
35 |
-
prompt_text =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
if show_details and additional_details:
|
38 |
prompt_text += f"\n\nAdditional Context Provided by the User:\n{additional_details}"
|
@@ -45,7 +53,7 @@ if uploaded_file and openai.api_key and analyze_button:
|
|
45 |
|
46 |
try:
|
47 |
# Make the request to OpenAI and handle streaming if required
|
48 |
-
response = openai.
|
49 |
st.write(response.choices[0].message.content)
|
50 |
except Exception as e:
|
51 |
st.error(f"An error occurred: {e}")
|
|
|
27 |
additional_details = st.text_area("Add any additional details or context about the image here:")
|
28 |
|
29 |
# Button to trigger the analysis
|
30 |
+
analyze_button = st.button("Analyse the MTSS Image")
|
31 |
|
32 |
if uploaded_file and openai.api_key and analyze_button:
|
33 |
+
with st.spinner("Analyzing the image..."):
|
34 |
base64_image = encode_image(uploaded_file)
|
35 |
+
prompt_text = (
|
36 |
+
"You are a highly knowledgeable scientific image analysis expert. "
|
37 |
+
"Your task is to examine the following image in detail. "
|
38 |
+
"Provide a comprehensive, factual, and scientifically accurate explanation of what the image depicts. "
|
39 |
+
"Highlight key elements and their significance, and present your analysis in clear, well-structured markdown format. "
|
40 |
+
"If applicable, include any relevant scientific terminology to enhance the explanation. "
|
41 |
+
"Assume the reader has a basic understanding of scientific concepts."
|
42 |
+
"Create a detailed image caption in bold explaining in short."
|
43 |
+
)
|
44 |
|
45 |
if show_details and additional_details:
|
46 |
prompt_text += f"\n\nAdditional Context Provided by the User:\n{additional_details}"
|
|
|
53 |
|
54 |
try:
|
55 |
# Make the request to OpenAI and handle streaming if required
|
56 |
+
response = openai.chat.completions.create(model="gpt-4-vision-preview", messages=messages, max_tokens=1200)
|
57 |
st.write(response.choices[0].message.content)
|
58 |
except Exception as e:
|
59 |
st.error(f"An error occurred: {e}")
|