o
    Xh                     @   sH   d dl Z d dlZd dlZdd Zedkr e Zes"ed dS dS dS )    Nc               
   C   sN  zt d z
ddlm} m} W n ty"   t d t d Y W dS w ttddr1tj	tj
}n
tj	tjt}tj|dd	}tj|d
d t d|  t d | d}|| t d |d}|| t d|  |tjd< t d|  W d
S  ty } zt dt|  t d t  W Y d }~dS d }~ww )NzStarting model download...r   )GroundingDinoProcessorGroundingDinoForObjectDetectionz^ERROR: Failed to import from transformers. Make sure you have installed the required packages:zpip install transformers torchFfrozenmodelszgrounding-dinoT)exist_okzModel will be saved to: zDownloading processor...z!IDEA-Research/grounding-dino-basezDownloading model...u1   ✅ Model and processor downloaded and saved to: 	MODEL_DIRu+   ✅ MODEL_DIR environment variable set to: z!ERROR: Failed to download model: z
Traceback:)printtransformersr   r   ImportErrorgetattrsysospathdirname
executableabspath__file__joinmakedirsfrom_pretrainedsave_pretrainedenviron	Exceptionstr	traceback	print_exc)r   r   current_dir	model_dir	processormodele r!   @/var/www/html/construction_image-detection-poc/download_model.pydownload_model   s@   




r#   __main__   )r   r   r   r#   __name__successexitr!   r!   r!   r"   <module>   s    2