Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -63,20 +63,20 @@ def plot_sensor_data(df):
|
|
63 |
plt.close(fig)
|
64 |
return Image.open(fig_path)
|
65 |
|
66 |
-
pipe = pipeline("
|
67 |
|
68 |
# Generate recommendations
|
69 |
def analyze_data(image, plot_path):
|
70 |
try:
|
71 |
-
# Ensure
|
72 |
if isinstance(image, np.ndarray):
|
73 |
image = Image.fromarray(image)
|
74 |
|
75 |
# Damage analysis
|
76 |
-
damage_output = pipe(
|
77 |
|
78 |
# Graph analysis
|
79 |
-
graph_analysis = pipe(
|
80 |
|
81 |
# Recommendations
|
82 |
recommendations = f"Recommendations based on analysis:\n\n1. {graph_analysis}\n\n2. {damage_output}"
|
@@ -85,7 +85,6 @@ def analyze_data(image, plot_path):
|
|
85 |
except Exception as e:
|
86 |
return f"Error occurred: {str(e)}", None, None
|
87 |
|
88 |
-
|
89 |
# Gradio UI
|
90 |
with gr.Blocks(css=".output-text { font-family: 'Arial'; color: #222; font-size: 1rem; }") as app:
|
91 |
gr.Markdown("# π Car Health Report Generation using Generative AI")
|
|
|
63 |
plt.close(fig)
|
64 |
return Image.open(fig_path)
|
65 |
|
66 |
+
pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
|
67 |
|
68 |
# Generate recommendations
|
69 |
def analyze_data(image, plot_path):
|
70 |
try:
|
71 |
+
# Ensure image is a PIL object
|
72 |
if isinstance(image, np.ndarray):
|
73 |
image = Image.fromarray(image)
|
74 |
|
75 |
# Damage analysis
|
76 |
+
damage_output = pipe(inputs=image)[0]['generated_text'] if image else "No image uploaded."
|
77 |
|
78 |
# Graph analysis
|
79 |
+
graph_analysis = pipe(inputs=plot_path)[0]['generated_text']
|
80 |
|
81 |
# Recommendations
|
82 |
recommendations = f"Recommendations based on analysis:\n\n1. {graph_analysis}\n\n2. {damage_output}"
|
|
|
85 |
except Exception as e:
|
86 |
return f"Error occurred: {str(e)}", None, None
|
87 |
|
|
|
88 |
# Gradio UI
|
89 |
with gr.Blocks(css=".output-text { font-family: 'Arial'; color: #222; font-size: 1rem; }") as app:
|
90 |
gr.Markdown("# π Car Health Report Generation using Generative AI")
|