Zaherrr commited on
Commit
2cd6b7d
·
verified ·
1 Parent(s): 6adaa4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -36,25 +36,24 @@ def reshape_json_data_to_fit_visualize_graph(graph_data):
36
  return graph_data
37
 
38
 
 
39
  def display_example(index):
40
  example = dataset[index]
41
- # print("This is the example: ")
42
- # print(example)
43
- # Get the image
44
  img = example["image"]
45
 
46
  # Prepare the graph data
47
  graph_data = {"nodes": example["nodes"], "edges": example["edges"]}
48
 
49
- # # Convert graph_data to JSON string
50
- # json_data = json.dumps(graph_data)
51
  transformed_graph_data = reshape_json_data_to_fit_visualize_graph(graph_data)
52
 
53
- # print(json_data)
54
  # Generate the graph visualization
55
  graph_html = visualize_graph(transformed_graph_data)
56
 
57
- return img, graph_html
 
 
 
 
58
 
59
 
60
  def create_interface():
@@ -73,7 +72,7 @@ def create_interface():
73
  index_slider.change(
74
  fn=display_example,
75
  inputs=[index_slider],
76
- outputs=[image_output, graph_output],
77
  )
78
 
79
  return demo
 
36
  return graph_data
37
 
38
 
39
+
40
  def display_example(index):
41
  example = dataset[index]
 
 
 
42
  img = example["image"]
43
 
44
  # Prepare the graph data
45
  graph_data = {"nodes": example["nodes"], "edges": example["edges"]}
46
 
 
 
47
  transformed_graph_data = reshape_json_data_to_fit_visualize_graph(graph_data)
48
 
 
49
  # Generate the graph visualization
50
  graph_html = visualize_graph(transformed_graph_data)
51
 
52
+ # Convert graph_data to a formatted JSON string
53
+ json_data = json.dumps(transformed_graph_data, indent=2)
54
+
55
+ return img, graph_html, json_data, transformed_graph_data
56
+
57
 
58
 
59
  def create_interface():
 
72
  index_slider.change(
73
  fn=display_example,
74
  inputs=[index_slider],
75
+ outputs=[image_output, graph_output, json_output, text_output],
76
  )
77
 
78
  return demo