AkashMnd commited on
Commit
d2d37d9
1 Parent(s): e6bcf99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -50,7 +50,7 @@ def send_to_openai(api_key, image_file):
50
  "content": [
51
  {
52
  "type": "text",
53
- "text": "Answer in three words only, does the image uploaded have a healthy rice leaf - Yes or No , does the image uploaded have a rice leaf with Major (not small) circular spots - Yes or No , does the image uploaded have a rice leaf have a major yellowish discoloration in some areas (ignore spots) - Yes or No , DO NOT RESPOND IN MORE THAN THREE WORDS "
54
  },
55
  {
56
  "type": "image_url",
@@ -73,7 +73,7 @@ def send_to_openai(api_key, image_file):
73
  "content": [
74
  {
75
  "type": "text",
76
- "text": "ANSWER IN ONLY ONE WORD , does the sheath part of the paddy in the image have sheath rot "
77
  },
78
  {
79
  "type": "image_url",
@@ -91,13 +91,15 @@ def send_to_openai(api_key, image_file):
91
  response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
92
  assistant_response = response.json()['choices'][0]['message']['content']
93
  recognition = assistant_response.split('\n')
94
- return ' '.join(words), ' '.join(recognition)
 
 
95
 
96
  iface = gr.Interface(
97
  fn=send_to_openai,
98
  inputs=["text", "file"],
99
- outputs=["text", "text"],
100
  title="Rice Leaf Disease Detection Demo Using GPT-4V(ision)",
101
  description="Made By Akash Mondal - https://github.com/akash-mondal GPT-4Vision Paper - https://cdn.openai.com/papers/GPTV_System_Card.pdf "
102
  )
103
- iface.launch()
 
50
  "content": [
51
  {
52
  "type": "text",
53
+ "text": "Answer in three words only, does the image uploaded have a healthy rice leaf - Yes or No , does the image uploaded have a rice leaf with Major (not small) circular spots - Yes or No , does the image uploaded have a rice leaf have a major yellowish discoloration in some areas (ignore spots) - Yes or No , DO NOT RESPOND IN MORE THAN THREE WORDS and ANSWER WITH COMMA IN THE MIDDLE OF THE WORDS WITH NO FULLSTOP "
54
  },
55
  {
56
  "type": "image_url",
 
73
  "content": [
74
  {
75
  "type": "text",
76
+ "text": "ANSWER IN ONLY ONE WORD , does the sheath part of the paddy in the image have sheath rot ANSWER IN YES OR NO , NO FULLSTOP "
77
  },
78
  {
79
  "type": "image_url",
 
91
  response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
92
  assistant_response = response.json()['choices'][0]['message']['content']
93
  recognition = assistant_response.split('\n')
94
+ result_string = ' '.join(words + recognition)
95
+ return result_string
96
+
97
 
98
  iface = gr.Interface(
99
  fn=send_to_openai,
100
  inputs=["text", "file"],
101
+ outputs=["text"],
102
  title="Rice Leaf Disease Detection Demo Using GPT-4V(ision)",
103
  description="Made By Akash Mondal - https://github.com/akash-mondal GPT-4Vision Paper - https://cdn.openai.com/papers/GPTV_System_Card.pdf "
104
  )
105
+ iface.launch(debug=True)