o
    Xh3                     @   sV   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 g dZ
G dd dZd	S )
    )
UploadFile)AsyncSession)SavingInputImage)ImageComparator)ImageComparison)za stack of wooden logsza concrete mixer machinezmetal rebar rodszconstruction scaffoldingza construction doorza pile of brickszmetal shuttering panelsc                   @   s0   e Zd ZdedefddZdedefddZd	S )
PredictionPipelinedbidc                 C   s   || _ || _d S )Nr   r	   )selfr   r	    r   G/var/www/html/construction_image-detection-poc/src/pipeline/pipeline.py__init__   s   
zPredictionPipeline.__init__before_imageafter_imagec                    s   t | j| jd}|||I d H }|d }|d }|d }t| jd}|j|||dI d H }	t| jd}
|
j||t|ddd	I d H }d
||d |d |	d d|dS )Nr
   prediction_idbefore_path
after_path)r   )r   r   r   g?g333333?)r   r   candidate_labelsr   iou_thresholdscore_thresholdzPipeline executed successfully
before_url	after_urlcomparison_report	completed)messager   r   r   text_resultsstatusoutput_image_url)	r   r   r	   saving_input_imagesr   run_comparisonr   compare_and_annotater   )r   r   r   saversave_resultr   r   r   
comparatorcomparison_resultcomaprator2comparison_result2r   r   r   run_pipeline   s:   zPredictionPipeline.run_pipelineN)__name__
__module____qualname__r   intr   r   r(   r   r   r   r   r      s    r   N)fastapir   sqlalchemy.ext.asyncior   src.components.input_imagesr   src.components.comparisonr   src.components.image_comparisonr   r   r   r   r   r   r   <module>   s    