-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefect.py
More file actions
58 lines (45 loc) · 2.56 KB
/
Copy pathdefect.py
File metadata and controls
58 lines (45 loc) · 2.56 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import streamlit as st
from dotenv import load_dotenv
load_dotenv()
import google.generativeai as genai
from PIL import Image
st.set_page_config('DEFECT AI',page_icon='🚀',layout='wide')
st.title("AI POWERED DEFECT ANALYZER 🧑🏻💻֎🇦🇮🧠👾")
st.header(':blue[Prototype of automated structural defect analyzer using AI] 🔧🤖 ')
st.subheader(':red[AI powered structural defect analysis using StreamLit that allows users to upload the image of any structural defects and to get suggessions and recomentations for repair and rebuilt]🚧')
with st.expander('📋 About the app:'):
st.markdown(f'''This app helps to detect the defects like cracks, misallignments etc and provide
- ** Defect Detection**
- ** Recomendation**
''')
import os
key=os.getenv('GOOGLE_API_KEY')
genai.configure(api_key=key)
input_image=st.file_uploader('Upload your file hear 📤',type=['png','jpeg','jpg'])
img=''
if input_image:
img=Image.open(input_image).convert('RGB')
st.image(img,caption='Uploaded Sucessfully')
prompt=f'''You are a quality engineer and a civil engineer, you need to analyze the input image and provide
necessary details for the below given questions in bullet points (max 3 points for each questions)
1.Identify the type of structural defect in the given image like cracks, bends and misallignment
2.Identify the level of defect if there are many cracks or bents it is highly damaged else low damaged
3.Find the exact way how the defect would have been caused considering material and environmental damage
4.Analyse will this defect cause further defects, if yes how severe it would be
5.Find different options to repair the defects immediatly
6.Analyse and give suggestions to consider while reparing so the reoccurance of the defect will be minimal chance
7.Suggest top 3 ideas to repair with the cost involved and material involved
8.How fast should the repair work begin based on the severiaty of the damage
9.Find if the defect would cause damage to the near by surrounding
10.How many days will be required to repair'''
model=genai.GenerativeModel('gemini-2.5-flash-lite')
def generate_result(prompt,img):
result=model.generate_content(f'''using the given {prompt} and given {img} analyze the image
and give the results as per the given prompt''')
return result.text
submit=st.button('Analyze the image')
if submit:
with st.spinner('Results Loading '):
response=generate_result(prompt,img)
st.markdown('## :green[Results]')
st.write(response)