Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import google.generativeai as genai
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
from langdetect import detect
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
api_key = "AIzaSyCmmus8HFPLXskU170_FR4j2CQeWZBKGMY"
|
| 8 |
+
|
| 9 |
+
model = genai.GenerativeModel('gemini-pro-vision')
|
| 10 |
+
genai.configure(api_key = api_key)
|
| 11 |
+
|
| 12 |
+
def pipeline(img):
|
| 13 |
+
try:
|
| 14 |
+
return score = model.generate_content(content=[f"Describe any damage (broken furniture, stains, etc.) in the given image. Also give the cost (in INR) for every damage sustained. Image: ", img])
|
| 15 |
+
except Exception:
|
| 16 |
+
return "No damage sustained"
|
| 17 |
+
|
| 18 |
+
iface = gr.Interface(
|
| 19 |
+
fn = pipeline,
|
| 20 |
+
inputs = gr.Image(label="Room Image", sources=['upload'], type="pil"),
|
| 21 |
+
outputs = ["text"]
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
iface.launch()
|