Rishit commited on
Commit
a3f7765
·
verified ·
1 Parent(s): 7630cf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -3,23 +3,25 @@ import requests
3
 
4
  API_URL = "https://ai-research.quarkgen.ai/templedekho/vastu/v1"
5
 
6
- def get_vastu_advice(question, image):
7
- image_file = {'image_path': image}
8
- data = {'question': question}
 
 
 
 
9
 
10
- response = requests.post(API_URL, files=image_file, data=data)
11
-
12
  if response.status_code == 200:
13
  return response.text
14
  else:
15
- return f"Error: {response.json()['error']}"
16
 
17
  # Gradio interface
18
  iface = gr.Interface(
19
  fn=get_vastu_advice,
20
  inputs=[
21
  gr.Textbox(label="Question"),
22
- gr.Image(type="file", label="Upload House Image (JPEG/PNG)")
23
  ],
24
  outputs=gr.Textbox(label="Vastu Prediction"),
25
  title="AI Vastu Astrologer"
@@ -27,3 +29,5 @@ iface = gr.Interface(
27
 
28
  if __name__ == "__main__":
29
  iface.launch(share=True)
 
 
 
3
 
4
  API_URL = "https://ai-research.quarkgen.ai/templedekho/vastu/v1"
5
 
6
+ def get_vastu_advice(question, image_path):
7
+ # Open the image file and prepare for upload
8
+ with open(image_path, 'rb') as image_file:
9
+ files = {'image_path': image_file}
10
+ data = {'question': question}
11
+
12
+ response = requests.post(API_URL, files=files, data=data)
13
 
 
 
14
  if response.status_code == 200:
15
  return response.text
16
  else:
17
+ return f"Error: {response.json().get('error', 'Unknown error')}"
18
 
19
  # Gradio interface
20
  iface = gr.Interface(
21
  fn=get_vastu_advice,
22
  inputs=[
23
  gr.Textbox(label="Question"),
24
+ gr.Image(type="filepath", label="Upload House Image (JPEG/PNG)")
25
  ],
26
  outputs=gr.Textbox(label="Vastu Prediction"),
27
  title="AI Vastu Astrologer"
 
29
 
30
  if __name__ == "__main__":
31
  iface.launch(share=True)
32
+
33
+