osanseviero commited on
Commit
10364bf
·
verified ·
1 Parent(s): 8382480

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
 
3
  import gradio as gr
@@ -33,18 +34,15 @@ def parse_json(json_output):
33
  json_output = "\n".join(lines[i+1:]) # Remove everything before "```json"
34
  json_output = json_output.split("```")[0] # Remove everything after the closing "```"
35
  break # Exit the loop once "```json" is found
36
- return json_output
37
 
38
  def parse_info(image, json_data):
39
  width, height = image.size
40
  df_data = []
41
  boxes_with_labels = []
42
 
43
- if not isinstance(json_data, list):
44
- return boxes_with_labels, pd.DataFrame(df_data)
45
-
46
  # Iterate over each detected action actions
47
- for action in info:
48
  box_2d = action.get("box_2d")
49
  label = action.get("label")
50
  co2_grams = action.get("co2_grams")
 
1
+ import json
2
  import os
3
 
4
  import gradio as gr
 
34
  json_output = "\n".join(lines[i+1:]) # Remove everything before "```json"
35
  json_output = json_output.split("```")[0] # Remove everything after the closing "```"
36
  break # Exit the loop once "```json" is found
37
+ return json.loads(json_output)
38
 
39
  def parse_info(image, json_data):
40
  width, height = image.size
41
  df_data = []
42
  boxes_with_labels = []
43
 
 
 
 
44
  # Iterate over each detected action actions
45
+ for action in json_data:
46
  box_2d = action.get("box_2d")
47
  label = action.get("label")
48
  co2_grams = action.get("co2_grams")