In the automotive manufacturing industry, project managers face the challenge of efficiently planning and scheduling complex product development projects. Traditional methods of project planning often lack precision and struggle to account for the intricacies of design sketches and resource utilization. As a result, project timelines may be inaccurate, leading to delays, cost overruns, and decreased competitiveness in the market.
Furthermore, the manual analysis of design sketches and the creation of detailed schedules are time-consuming tasks that require specialized expertise, hindering the efficiency of project managers and delaying project execution.
Therefore, there is a need for an innovative solution that leverages artificial intelligence and automation to analyze design sketches, extract relevant information, and generate detailed project plans and schedules. This solution should provide project managers with a streamlined and intuitive tool to effectively plan and execute automotive manufacturing projects, ultimately improving productivity, reducing costs, and enhancing competitiveness in the industry.
Introducing the Product Scheduler
The Product Scheduler is an interactive web application designed to assist project managers in the automotive industry with project planning, initiation, and schedule development. By leveraging Lyzr Automata and OpenAI GPT-4o, this tool analyzes design sketches of products and generates detailed monthly schedules based on the input.
Key Features
File Upload: Users can upload design sketches of products directly to the application.
AI-Powered Generation: Upon uploading the sketch, the application leverages the GPTVISION model to analyze the design and generate detailed project plans and schedules.
Interactive Interface: The application provides an intuitive interface for users to interact with and visualize the generated schedules.
How It Works
Uploading Design Sketch: Users start by uploading a design sketch of the product they want to schedule. Supported file formats include PNG and JPG.
AI Analysis: Once the sketch is uploaded, the GPTVISION model analyzes the design and extracts relevant information such as features, parts, and resource utilization.
Schedule Generation: Based on the analysis, the model generates detailed monthly schedules with columns including month, task, week, and description.
Output Display: The generated schedules are displayed to the user within the application interface, providing a clear overview of the project timeline and tasks.
Step-by-Step Guide
Setting Up the App:
pip install lyzr-automata streamlit pillow
gptvision.py
from typing import Any, Dict, List
from lyzr_automata.ai_models.model_base import AIModel
from openai import OpenAI
from lyzr_automata.data_models import FileResponse
from lyzr_automata.utils.resource_handler import ResourceBox
class GPTVISION(AIModel):
def __init__(self, api_key, parameters: Dict[str, Any]):
self.parameters = parameters
self.client = OpenAI(api_key=api_key)
self.api_key = api_key
def generate_text(
self,
task_id: str=None,
system_persona: str=None,
prompt: str=None,
image_url: str=None,
messages: List[dict] = None,
):
if messages is None:
messages = [
{"role": "user", "content": [
{"type": "text",
"text": prompt
},
{
"type": "image_url",
"image_url": {
"url": f"data:image/jpeg;base64,{image_url}",
},
},
]
},
]
response = self.client.chat.completions.create(
**self.parameters,
model="gpt-4o",
messages=messages,
)
return response.choices[0].message.content
def generate_image(
self, task_id: str, prompt: str, resource_box: ResourceBox
) -> FileResponse:
pass
This code defines a class GPTVISION that inherits from Lyzr Automata'sAIModel. It interacts with the OpenAI API to generate text based on user prompts and potentially images.
It takes an API key and parameters during initialization.
The generate_text function builds a message containing the prompt and optionally an image URL.
It sends this message to the gpt-4o model for text completion and returns the generated response.
The generate_image function is not implemented here.
App.py
from gptvision import GPTVISION
import streamlit as st
from PIL import Image
import utils
import base64
import os
Imports necessary libraries like GPTVISION from gptvision, streamlit for the web app, PIL for image processing, and utility functions from utils.Imports necessary libraries like GPTVISION from gptvision, streamlit for the web app, PIL for image processing, and utility functions from utils.
OpenAI API Key Validation:
api = st.sidebar.text_input("Enter Your OPENAI API KEY HERE",type="password")
if api:
openai_4o_model = GPTVISION(api_key=api,parameters={})
else:
st.sidebar.error("Please Enter Your OPENAI API KEY")
Takes user input for their OpenAI API key through a password field in the sidebar.
Checks if the API key is entered.
If not, displays an error message in the sidebar asking the user to enter the key.
Uploading Construction Map:
data = "data"
os.makedirs(data, exist_ok=True)
def encode_image(image_path):
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode('utf-8')
Creates a folder named data to store uploaded files.
Defines a function encode_image that takes an image path, opens the image in binary mode, and encodes it to base64 format for sending to the OpenAI API.
GPT Model and Prompt:
prompt = f"""
You are an Expert Project Manager in Automotive industry.Your Task is to create Project Planning,Initiation and Schedule Development.
Follow Below Instructions:
1/ Analyze given Design and Note all features and parts carefully.
2/ Think About Resource utilise in Manufacturing process.
3/ Make Planning to build this design in realistic model.
4/ Develop Detailed Monthly schedule table with following columns month,Task,week,Description.
Output Requirements:
Detailed Monthly schedule table with following columns month,Task,week,Description.
"""
This defines a multi-line string variable containing the prompt instructions for the GPTVISION model. The prompt describes the user’s role as an expert project manager and outlines the steps for project planning and scheduling based on a product design sketch.
Uploading and Processing:
uploaded_files = st.file_uploader("Upload Nit sketch of product", type=['png', 'jpg'])
if uploaded_files is not None:
st.success(f"File uploaded: {uploaded_files.name}")
file_path = utils.save_uploaded_file(uploaded_files)
if file_path is not None:
st.sidebar.image(file_path)
if st.button("Generate"):
encoded_image = encode_image(file_path)
planning = openai_4o_model.generate_text(prompt=prompt, image_url=encoded_image)
st.markdown(planning)
uploaded_files = st.file_uploader: This creates a file upload element in the Streamlit app allowing users to upload files of types 'png' and 'jpg'.
if uploaded_files is not None:: This checks if a file has been uploaded.
st.success: This displays a success message with the uploaded file name.
file_path = utils.save_uploaded_file(uploaded_files): This calls a function from the utils module likely responsible for saving the uploaded file and returning its path.
if file_path is not None:: This checks if the file was saved successfully.
if st.button("Generate"):: This creates a button labeled "Generate" in the app. Clicking this button triggers the following code block when pressed.
encoded_image = encode_image(file_path): This calls the encode_image function to convert the uploaded image at file_path to a base64 encoded string.
planning = openai_4o_model.generate_text(prompt=prompt, image_url=encoded_image): This calls the generate_text method of the openai_4o_model instance. It sends the defined prompt and the encoded image (encoded_image) as arguments. This likely interacts with the OpenAI API to generate text based on the prompt and the image content. The generated text (presumably the project schedule) is stored in the planning variable.
st.markdown(planning): This displays the generated project schedule (planning) as markdown formatted text in the Streamlit app.
try it now: https://lyzr-scheduler.streamlit.app/
For more information explore the website: Lyzr
Top comments (0)