Commit b3e7bf19 authored by Weerasinghe D.N.H's avatar Weerasinghe D.N.H

BACKEND : multiplicity detection code added

parent c0fb57b3
No preview for this file type
from config.database import db
class Multiplicity(db.Model):
id = db.Column(db.Integer, primary_key=True)
value = db.Column(db.String(50))
relationship_id = db.Column(db.String(50))
x_min = db.Column(db.String(50), nullable=False)
y_min = db.Column(db.String(50), nullable=False)
x_max = db.Column(db.String(50), nullable=False)
y_max = db.Column(db.String(50), nullable=False)
def __repr__(self) -> str:
return 'Class_Multiplicity>>> {self.content}'
digraph "classes_xjhuiklcyw" {
rankdir=BT
charset="utf-8"
"xjhuiklcyw.Admin" [color="black", fontcolor="black", label="{Admin|\l|check_the_payments_and_sold_items()\llogin_to_the_system()\lreply_to_Customer_feedbacks()\lview_and_manage_cart_items()\l}", shape="record", style="solid"];
}
digraph "classes_zmvecfvrja" {
rankdir=BT
charset="utf-8"
"zmvecfvrja.Admin" [color="black", fontcolor="black", label="{Admin|\l|approve_the_planned_mileage_modification_request_submitted_by_the_WarehouseIncharge()\ledit_the_eligibility_criteria_for_driver_incentive()\ledit_the_per_km_rate_for_an_existing_vehicle_capacity_type()\lmodify_the___drop_off___rate_table()\lmodify_the_minimum_fix_mileage_configuration_for_a_job()\lmodify_the_unloading_charge()\lset_up_the___drop_off___rate_table_based_on_number_of_outlets_visited()\lupdate_the_radius_limit_from_a_warehouse_for___drop_off___charges()\l}", shape="record", style="solid"];
"zmvecfvrja.WarehouseIncharge" [color="black", fontcolor="black", label="{WarehouseIncharge|\l|approve_a_job()\lconfirm_the_delivered_items_to_a_outlet()\lrequest_a_modification_to_the_planned_mileage_of_a_job()\l}", shape="record", style="solid"];
"zmvecfvrja.WarehouseOperator" [color="black", fontcolor="black", label="{WarehouseOperator|\l|allocate_a_vehicle_for_a_job()\lchange_the_system_suggested_optimized_route_if_required()\lchange_the_vehicle_allocated_for_a_job()\lconfirm_a_job()\lcreate_orders_by_uploading_a_csv_file()\lexport_information_of_a_job_to_pdf_and_xls_format()\lgenerate_an_idle_time_limit_violation_report()\lgenerate_an_invoice_for_each_vehicle()\lgenerate_cost_per_1_kg_report()\lgenerate_outlet_wise_transport_cost_report_for_a_given_date_range()\lgenerate_vehicle_capacity_utilization_report()\lgenerate_vehicle_turnaround_time_report_for_a_warehouse()\lindicate_that_the_loading_is_completed()\lmake_adjustments_to_the_order()\l}", shape="record", style="solid"];
}
digraph G {
rankdir=LR;
labelloc="b";
peripheries=0;
node [shape=plaintext]
subgraph Admin {label="Admin"; admin};
admin [image="D:\Nanduni.Bsc\research_code\2022-158\backend/stick.png";peripheries=0;];
node [shape=ellipse, style=solid];
login_to_the_system [label="Login To The System"];
check_the_home_page [label="Check The Home Page"];
play_the_site_demo_video [label="Play The Site Demo Video"];
add_items_to_the_cart [label="Add Items To The Cart"];
pay_the_items [label="Pay The Items"];
give_a_feedback_for_the_system [label="Give A Feedback For The System"];
view_the_seller_details [label="View The Seller Details"];
contact_the_seller_to_request_more_items [label="Contact The Seller To Request More Items"];
login_to_the_system [label="Login To The System"];
view_and_manage_cart_items [label="View And Manage Cart Items"];
check_the_payments_and_sold_items [label="Check The Payments And Sold Items"];
reply_to_customer_feedbacks [label="Reply To Customer Feedbacks"];
edge [arrowhead="none"];
customer->login_to_the_system;
customer->check_the_home_page;
customer->play_the_site_demo_video;
customer->add_items_to_the_cart;
customer->pay_the_items;
customer->give_a_feedback_for_the_system;
customer->view_the_seller_details;
customer->contact_the_seller_to_request_more_items;
admin->login_to_the_system;
admin->view_and_manage_cart_items;
admin->check_the_payments_and_sold_items;
admin->reply_to_customer_feedbacks;
edge [arrowtail="vee", label="<<extend>>", style=dashed];
give_a_feedback_for_the_system->rate_the_service;
edge [arrowtail="vee", label="<<include>>", style=dashed];
pay_the_items->recieve_the_confirmation_email;
}
\ No newline at end of file
digraph G {
rankdir=LR;
labelloc="b";
peripheries=0;
node [shape=plaintext]
subgraph Admin {label="Admin"; admin};
admin [image="D:\Nanduni.Bsc\research_code\2022-158\backend/stick.png";peripheries=0;];
node [shape=ellipse, style=solid];
login_to_the_system [label="Login To The System"];
check_the_home_page [label="Check The Home Page"];
play_the_site_demo_video [label="Play The Site Demo Video"];
add_items_to_the_cart [label="Add Items To The Cart"];
pay_the_items [label="Pay The Items"];
give_a_feedback_for_the_system [label="Give A Feedback For The System"];
view_the_seller_details [label="View The Seller Details"];
contact_the_seller_to_request_more_items [label="Contact The Seller To Request More Items"];
login_to_the_system [label="Login To The System"];
view_and_manage_cart_items [label="View And Manage Cart Items"];
check_the_payments_and_sold_items [label="Check The Payments And Sold Items"];
reply_to_customer_feedbacks [label="Reply To Customer Feedbacks"];
edge [arrowhead="none"];
customer->login_to_the_system;
customer->check_the_home_page;
customer->play_the_site_demo_video;
customer->add_items_to_the_cart;
customer->pay_the_items;
customer->give_a_feedback_for_the_system;
customer->view_the_seller_details;
customer->contact_the_seller_to_request_more_items;
admin->login_to_the_system;
admin->view_and_manage_cart_items;
admin->check_the_payments_and_sold_items;
admin->reply_to_customer_feedbacks;
edge [arrowtail="vee", label="<<extend>>", style=dashed];
give_a_feedback_for_the_system->rate_the_service;
edge [arrowtail="vee", label="<<include>>", style=dashed];
pay_the_items->recieve_the_confirmation_email;
}
\ No newline at end of file
digraph G {
rankdir=LR;
labelloc="b";
peripheries=0;
node [shape=plaintext]
subgraph WarehouseOperator {label="WarehouseOperator"; warehouseoperator};
warehouseoperator [image="D:\Nanduni.Bsc\research_code\2022-158\backend/stick.png";peripheries=0;];
subgraph WarehouseIncharge {label="WarehouseIncharge"; warehouseincharge};
warehouseincharge [image="D:\Nanduni.Bsc\research_code\2022-158\backend/stick.png";peripheries=0;];
subgraph Admin {label="Admin"; admin};
admin [image="D:\Nanduni.Bsc\research_code\2022-158\backend/stick.png";peripheries=0;];
node [shape=ellipse, style=solid];
sign_up_to_the_system [label="Sign Up To The System"];
sign_in_to_the_system [label="Sign In To The System"];
create_orders_by_uploading_a_csv_file [label="Create Orders By Uploading A Csv File"];
make_adjustments_to_the_order [label="Make Adjustments To The Order"];
allocate_a_vehicle_for_a_job [label="Allocate A Vehicle For A Job"];
change_the_system_suggested_optimized_route_if_required [label="Change The System Suggested Optimized Route If Required"];
confirm_a_job [label="Confirm A Job"];
change_the_vehicle_allocated_for_a_job [label="Change The Vehicle Allocated For A Job"];
export_information_of_a_job_to_pdf_and_xls_format [label="Export Information Of A Job To Pdf And Xls Format"];
indicate_that_the_loading_is_completed [label="Indicate That The Loading Is Completed"];
confirm_the_delivered_items_to_a_outlet [label="Confirm The Delivered Items To A Outlet"];
approve_a_job [label="Approve A Job"];
request_a_modification_to_the_planned_mileage_of_a_job [label="Request A Modification To The Planned Mileage Of A Job"];
approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge [label="Approve The Planned Mileage Modification Request Submitted By The Warehouseincharge"];
generate_an_invoice_for_each_vehicle [label="Generate An Invoice For Each Vehicle"];
modify_the_minimum_fix_mileage_configuration_for_a_job [label="Modify The Minimum Fix Mileage Configuration For A Job"];
modify_the_unloading_charge [label="Modify The Unloading Charge"];
update_the_radius_limit_from_a_warehouse_for___drop_off___charges [label="Update The Radius Limit From A Warehouse For Drop Off Charges"];
set_up_the___drop_off___rate_table_based_on_number_of_outlets_visited [label="Set Up The Drop Off Rate Table Based On Number Of Outlets Visited"];
modify_the___drop_off___rate_table [label="Modify The Drop Off Rate Table"];
edit_the_eligibility_criteria_for_driver_incentive [label="Edit The Eligibility Criteria For Driver Incentive"];
edit_the_per_km_rate_for_an_existing_vehicle_capacity_type [label="Edit The Per Km Rate For An Existing Vehicle Capacity Type"];
generate_vehicle_capacity_utilization_report [label="Generate Vehicle Capacity Utilization Report"];
generate_outlet_wise_transport_cost_report_for_a_given_date_range [label="Generate Outlet Wise Transport Cost Report For A Given Date Range"];
generate_vehicle_turnaround_time_report_for_a_warehouse [label="Generate Vehicle Turnaround Time Report For A Warehouse"];
generate_cost_per_1_kg_report [label="Generate Cost Per 1 Kg Report"];
generate_an_idle_time_limit_violation_report [label="Generate An Idle Time Limit Violation Report"];
edge [arrowhead="none"];
user->sign_up_to_the_system;
user->sign_in_to_the_system;
warehouseoperator->create_orders_by_uploading_a_csv_file;
warehouseoperator->make_adjustments_to_the_order;
warehouseoperator->allocate_a_vehicle_for_a_job;
warehouseoperator->change_the_system_suggested_optimized_route_if_required;
warehouseoperator->confirm_a_job;
warehouseoperator->change_the_vehicle_allocated_for_a_job;
warehouseoperator->export_information_of_a_job_to_pdf_and_xls_format;
warehouseoperator->indicate_that_the_loading_is_completed;
warehouseincharge->confirm_the_delivered_items_to_a_outlet;
warehouseincharge->approve_a_job;
warehouseincharge->request_a_modification_to_the_planned_mileage_of_a_job;
admin->approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge;
warehouseoperator->generate_an_invoice_for_each_vehicle;
admin->modify_the_minimum_fix_mileage_configuration_for_a_job;
admin->modify_the_unloading_charge;
admin->update_the_radius_limit_from_a_warehouse_for___drop_off___charges;
admin->set_up_the___drop_off___rate_table_based_on_number_of_outlets_visited;
admin->modify_the___drop_off___rate_table;
admin->edit_the_eligibility_criteria_for_driver_incentive;
admin->edit_the_per_km_rate_for_an_existing_vehicle_capacity_type;
warehouseoperator->generate_vehicle_capacity_utilization_report;
warehouseoperator->generate_outlet_wise_transport_cost_report_for_a_given_date_range;
warehouseoperator->generate_vehicle_turnaround_time_report_for_a_warehouse;
warehouseoperator->generate_cost_per_1_kg_report;
warehouseoperator->generate_an_idle_time_limit_violation_report;
edge [arrowtail="vee", label="<<extend>>", style=dashed];
create_orders_by_uploading_a_csv_file->make_adjustments_to_the_order;
confirm_a_job->change_the_vehicle_allocated_for_a_job_change_the_system_suggested_optimized_route_if_required;
edge [arrowtail="vee", label="<<include>>", style=dashed];
confirm_a_job->allocate_a_vehicle_for_a_job;
approve_a_job->confirm_the_delivered_items_to_a_outlet;
request_a_modification_to_the_planned_mileage_of_a_job->approve_the_planned_mileage_modification_request_submitted_by_the_warehouseincharge;
}
\ No newline at end of file
import operator
import os
import re
import cv2
import numpy as np
import pytesseract as ts
from PIL import Image
from models.attribute_model import Attribute
from paddleocr import PaddleOCR, draw_ocr # main OCR dependencies
from object_detection.utils import label_map_util
import matplotlib.pyplot as plt
import app
import tensorflow as tf
import spacy
......@@ -17,6 +14,7 @@ import spacy
from config.database import db
from models.class_component_model import Component
from models.class_relationship_model import Relationship
from models.class_relationship_muplicity import Multiplicity
from models.method_model import Method
ts.pytesseract.tesseract_cmd = r'C:\Users\DELL\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'
......@@ -44,10 +42,11 @@ def component_separation(filename, class_comp_id):
if category == 'class':
print(filename)
class_details_detection(image_nparray, boxes, index, class_comp_id, category)
# class_details_detection(image_nparray, boxes, index, class_comp_id, category)
elif category == 'interface':
class_details_detection(image_nparray, boxes, index, class_comp_id, category)
print(filename, 'interface')
# class_details_detection(image_nparray, boxes, index, class_comp_id, category)
else:
relationship_details_detection(image_nparray, boxes, index, class_comp_id, category)
......@@ -264,10 +263,51 @@ def save_class_interface(class_type, comp_name, cl_ymin, cl_xmin, cl_ymax, cl_xm
def relationship_details_detection(image_nparray, boxes, index, class_comp_id, category):
_image, y_min, x_min, y_max, x_max = crop_image_(image_nparray, boxes, index)
_image = cv2.resize(_image, None, fx=1, fy=1)
relationship = Relationship(class_answer=class_comp_id, name='', type=category, x_min=x_min, y_min=y_min,
_image = cv2.resize(_image, None, fx=4, fy=5)
ocr_model = PaddleOCR(lang='en', use_gpu=False)
result = ocr_model.ocr(_image)
relationship = Relationship(class_answer=class_comp_id, type=category, x_min=x_min, y_min=y_min,
x_max=x_max,
y_max=y_max)
db.session.add(relationship)
db.session.commit()
if result is not None:
relationship_text(_image, result, relationship)
print(relationship, 'relationship')
def relationship_text(_image, result, relationship):
# boxes = [res[0] for res in result]
# texts = [res[1][0] for res in result]
# scores = [res[1][1] for res in result]
for element in result:
text = element[1][0]
box = element[0]
nlp_ner = spacy.load('ner_models/model-best')
nlp_output = nlp_ner(text)
print(text, 'line 290')
# box = np.array(box,dtype=float)
box = np.array(box).astype(np.int32)
xmin = min(box[:, 0])
ymin = min(box[:, 1])
xmax = max(box[:, 0])
ymax = max(box[:, 1])
for token in nlp_output.ents:
print(token, 'line 301')
if token.label == 'MULTIPLICITY' or contains_number(text):
multiplicity = Multiplicity(value=token.text, relationship_id=relationship.id, x_min=xmin,
y_min=ymin, x_max=xmax, y_max=ymax)
db.session.add(multiplicity)
db.session.commit()
if not contains_number(text):
relationship.name = text
db.session.commit()
def contains_number(string):
return any([char.isdigit() for char in string])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment