Skip to content

Commit eac74ef

Browse files
committed
Review some GenAI assets.
* Fix Python `oci` package versioning. * Update instructions slightly. * Git ignore temporary files or remove the need for them.
1 parent 392329d commit eac74ef

File tree

7 files changed

+16
-24
lines changed

7 files changed

+16
-24
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
temp_uploaded_image.*
2+
temp_uploaded_video.*

ai/generative-ai-service/decode-Images-and-Videos-with-OCI-GenAI/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is an AI-powered application designed to unlock insights hidden within medi
55

66
<img src="./image.png">
77
</img>
8-
Reviewed date: 22.09.2025
8+
Reviewed date: 09.10.2025
99

1010
## Features
1111

@@ -39,8 +39,7 @@ Reviewed date: 22.09.2025
3939

4040
## Installation
4141

42-
1. **Clone the repository:**
43-
42+
1. **Clone this repository.**
4443

4544
2. **Install dependencies:**
4645
Make sure you have Python 3.8+ installed. Then, install the required libraries:
@@ -50,7 +49,7 @@ Reviewed date: 22.09.2025
5049

5150
3. **Configure OCI:**
5251
- Set up your OCI configuration by creating or updating the `~/.oci/config` file with your credentials and profile.
53-
- Replace placeholders like `compartmentId`, `llm_service_endpoint`, and `visionModel` in the code with your actual values.
52+
- Replace placeholders like `compartmentId`, `llm_service_endpoint`, and `visionModel` in [`app.py`](./app.py) with your actual values.
5453

5554
---
5655

ai/generative-ai-service/decode-Images-and-Videos-with-OCI-GenAI/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def get_chat_request(encoded_image=None, user_prompt=None):
6161
return chat_request
6262

6363
def cohere_chat_request(encoded_image=None, user_prompt=None):
64-
print(" i am here")
6564
chat_request = oci.generative_ai_inference.models.CohereChatRequest()
6665
chat_request.api_format = oci.generative_ai_inference.models.BaseChatRequest.API_FORMAT_COHERE
6766
message = get_message(encoded_image, user_prompt)
@@ -92,7 +91,7 @@ def extract_frames(video_path, interval=1):
9291

9392
while success:
9493
if count % (frame_rate * interval) == 0:
95-
frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
94+
frames.append(frame)
9695
success, frame = cap.read()
9796
count += 1
9897
cap.release()
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
streamlit==1.37.0
2-
oci==3.50.1
2+
oci>=2.161.0,<3
33
Pillow
44
opencv-python-headless==4.10.0.84
5-
tqdm==4.66.3
5+
tqdm==4.66.3

ai/generative-ai-service/image-to-text/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
This application is built using **Streamlit** and **Oracle OCI Generative AI**, allowing users to upload an image, input a prompt, and receive a text-based response generated by the AI model. It leverages Oracle's Gen AI Inference API for processing multimodal data (text and image).
55

6-
Reviewed: 22.09.2025
6+
Reviewed: 09.10.2025
77

88
<img src="./image1.png">
99
</img>
@@ -38,8 +38,7 @@ Reviewed: 22.09.2025
3838

3939
## Installation
4040

41-
1. Clone the repository:
42-
41+
1. Clone this repository.
4342

4443
2. Install dependencies:
4544
```bash
@@ -49,6 +48,8 @@ Reviewed: 22.09.2025
4948
3. Configure OCI:
5049
Ensure your `~/.oci/config` file is set up with the correct credentials and profile.
5150

51+
4. Edit [`app.py`](./app.py) and insert a valid Compartment OCID.
52+
5253
---
5354

5455
## Usage

ai/generative-ai-service/image-to-text/app.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
llm_service_endpoint = "https://inference.generativeai.us-chicago-1.oci.oraclecloud.com"
1010

1111
# Define functions
12-
def encode_image(image_path):
13-
with open(image_path, "rb") as image_file:
14-
return base64.b64encode(image_file.read()).decode("utf-8")
15-
1612
def get_message(encoded_image, user_prompt):
1713
content1 = oci.generative_ai_inference.models.TextContent()
1814
content1.text = user_prompt
@@ -57,20 +53,15 @@ def get_chat_detail(chat_request):
5753
user_prompt = st.text_input("Enter your prompt for the image:", value="Tell me about this image.")
5854

5955
if uploaded_file:
60-
# Save the uploaded image temporarily
61-
temp_image_path = "temp_uploaded_image.jpg"
62-
with open(temp_image_path, "wb") as f:
63-
f.write(uploaded_file.getbuffer())
64-
6556
# Display the uploaded image
66-
st.image(temp_image_path, caption="Uploaded Image", use_column_width=True)
57+
st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)
6758

6859
# Process and call the model
6960
if st.button("Generate Response"):
7061
with st.spinner("Please wait while the model processes the image..."):
7162
try:
7263
# Encode the image
73-
encoded_image = encode_image(temp_image_path)
64+
encoded_image = base64.b64encode(uploaded_file.getvalue()).decode("utf-8")
7465

7566
# Setup OCI client
7667
CONFIG_PROFILE = "DEFAULT"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
streamlit==1.37.0
2-
oci==3.50.1
3-
Pillow
2+
oci>=2.161.0,<3
3+
Pillow

0 commit comments

Comments
 (0)