BenjiELCA commited on
Commit
b76c717
β€’
1 Parent(s): 6dcd36e

change folders

Browse files
app.py CHANGED
@@ -1,33 +1,29 @@
1
  import streamlit as st
2
  import streamlit.components.v1 as components
3
- from PIL import Image
4
  import torch
5
  from torchvision.transforms import functional as F
6
- from PIL import Image, ImageEnhance
7
- from htlm_webpage import display_bpmn_xml
8
  import gc
9
  import psutil
10
  import copy
11
-
12
-
13
- from OCR import text_prediction, filter_text, mapping_text, rescale
14
- from train import prepare_model
15
- from utils import draw_annotations, create_loader, class_dict, arrow_dict, object_dict
16
- from toXML import calculate_pool_bounds, add_diagram_elements
17
- from pathlib import Path
18
- from toXML import create_bpmn_object, create_flow_element
19
  import xml.etree.ElementTree as ET
20
  import numpy as np
21
- from display import draw_stream
22
- from eval import full_prediction
23
- from streamlit_image_comparison import image_comparison
24
  from xml.dom import minidom
 
 
 
 
 
 
 
 
 
 
 
25
  from streamlit_cropper import st_cropper
26
  from streamlit_drawable_canvas import st_canvas
27
  from streamlit_image_select import image_select
28
- from utils import find_closest_object
29
- from train import get_faster_rcnn_model, get_arrow_model
30
- import gdown
31
 
32
  def get_memory_usage():
33
  process = psutil.Process()
 
1
  import streamlit as st
2
  import streamlit.components.v1 as components
3
+ from PIL import Image, ImageEnhance
4
  import torch
5
  from torchvision.transforms import functional as F
 
 
6
  import gc
7
  import psutil
8
  import copy
 
 
 
 
 
 
 
 
9
  import xml.etree.ElementTree as ET
10
  import numpy as np
 
 
 
11
  from xml.dom import minidom
12
+ from pathlib import Path
13
+ import gdown
14
+
15
+ from modules.htlm_webpage import display_bpmn_xml
16
+ from modules.OCR import text_prediction, filter_text, mapping_text, rescale
17
+ from modules.utils import class_dict, arrow_dict, object_dict, find_closest_object
18
+ from modules.toXML import calculate_pool_bounds, add_diagram_elements, create_bpmn_object, create_flow_element
19
+ from modules.display import draw_stream
20
+ from modules.eval import full_prediction
21
+ from modules.train import get_faster_rcnn_model, get_arrow_model
22
+ from streamlit_image_comparison import image_comparison
23
  from streamlit_cropper import st_cropper
24
  from streamlit_drawable_canvas import st_canvas
25
  from streamlit_image_select import image_select
26
+
 
 
27
 
28
  def get_memory_usage():
29
  process = psutil.Process()
flask.py DELETED
@@ -1,6 +0,0 @@
1
- from flask import Flask
2
- app = Flask(__name__)
3
-
4
- @app.route("/")
5
- def hello():
6
- return "Hello World!\n"
 
 
 
 
 
 
 
OCR.py β†’ modules/OCR.py RENAMED
@@ -6,15 +6,21 @@ from azure.core.credentials import AzureKeyCredential
6
  import time
7
  import numpy as np
8
  import networkx as nx
9
- from eval import iou
10
- from utils import class_dict, proportion_inside
11
  import json
12
- from utils import rescale_boxes as rescale
 
13
 
14
 
15
  VISION_KEY = os.getenv("VISION_KEY")
16
  VISION_ENDPOINT = os.getenv("VISION_ENDPOINT")
17
 
 
 
 
 
 
 
18
 
19
  def sample_ocr_image_file(image_data):
20
  # Set the values of your computer vision endpoint and computer vision key
 
6
  import time
7
  import numpy as np
8
  import networkx as nx
9
+ from modules.utils import class_dict, proportion_inside
 
10
  import json
11
+ from modules.utils import rescale_boxes as rescale
12
+ import streamlit as st
13
 
14
 
15
  VISION_KEY = os.getenv("VISION_KEY")
16
  VISION_ENDPOINT = os.getenv("VISION_ENDPOINT")
17
 
18
+ #If local execution
19
+ """with open("VISION_KEY.json", "r") as json_file:
20
+ json_data = json.load(json_file)
21
+
22
+ VISION_KEY = json_data["VISION_KEY"]
23
+ VISION_ENDPOINT = json_data["VISION_ENDPOINT"]"""
24
 
25
  def sample_ocr_image_file(image_data):
26
  # Set the values of your computer vision endpoint and computer vision key
modules/__init__.py ADDED
File without changes
display.py β†’ modules/display.py RENAMED
@@ -1,9 +1,9 @@
1
- from utils import draw_annotations, create_loader, class_dict, resize_boxes, resize_keypoints, find_other_keypoint
2
  import cv2
3
  import numpy as np
4
  import torch
5
  import matplotlib.pyplot as plt
6
- from OCR import group_texts
7
 
8
 
9
 
 
1
+ from modules.utils import draw_annotations, create_loader, class_dict, resize_boxes, resize_keypoints, find_other_keypoint
2
  import cv2
3
  import numpy as np
4
  import torch
5
  import matplotlib.pyplot as plt
6
+ from modules.OCR import group_texts
7
 
8
 
9
 
eval.py β†’ modules/eval.py RENAMED
@@ -1,8 +1,8 @@
1
  import numpy as np
2
  import torch
3
- from utils import class_dict, object_dict, arrow_dict, find_closest_object, find_other_keypoint, filter_overlap_boxes, iou
4
  from tqdm import tqdm
5
- from toXML import create_BPMN_id
6
 
7
 
8
 
 
1
  import numpy as np
2
  import torch
3
+ from modules.utils import class_dict, object_dict, arrow_dict, find_closest_object, find_other_keypoint, filter_overlap_boxes, iou
4
  from tqdm import tqdm
5
+ from modules.toXML import create_BPMN_id
6
 
7
 
8
 
htlm_webpage.py β†’ modules/htlm_webpage.py RENAMED
File without changes
toXML.py β†’ modules/toXML.py RENAMED
@@ -1,5 +1,5 @@
1
  import xml.etree.ElementTree as ET
2
- from utils import class_dict
3
 
4
  def rescale(scale, boxes):
5
  for i in range(len(boxes)):
 
1
  import xml.etree.ElementTree as ET
2
+ from modules.utils import class_dict
3
 
4
  def rescale(scale, boxes):
5
  for i in range(len(boxes)):
train.py β†’ modules/train.py RENAMED
@@ -7,7 +7,7 @@ import torch
7
  import torchvision.transforms.functional as F
8
  import matplotlib.pyplot as plt
9
 
10
- from eval import main_evaluation
11
  from torch.optim import SGD, AdamW
12
  from torch.utils.data import DataLoader, Dataset, Subset, ConcatDataset
13
  from torch.utils.data.dataloader import default_collate
@@ -15,7 +15,7 @@ from torchvision.models.detection import keypointrcnn_resnet50_fpn, KeypointRCNN
15
  from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
16
  from torchvision.models.detection.keypoint_rcnn import KeypointRCNNPredictor
17
  from tqdm import tqdm
18
- from utils import write_results
19
 
20
 
21
 
 
7
  import torchvision.transforms.functional as F
8
  import matplotlib.pyplot as plt
9
 
10
+ from modules.eval import main_evaluation
11
  from torch.optim import SGD, AdamW
12
  from torch.utils.data import DataLoader, Dataset, Subset, ConcatDataset
13
  from torch.utils.data.dataloader import default_collate
 
15
  from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
16
  from torchvision.models.detection.keypoint_rcnn import KeypointRCNNPredictor
17
  from tqdm import tqdm
18
+ from modules.utils import write_results
19
 
20
 
21
 
utils.py β†’ modules/utils.py RENAMED
File without changes