Load the SamGeo model.
(self)
| 768 | self.output_path_edit.setText(file_path) |
| 769 | |
| 770 | def load_model(self): |
| 771 | """Load the SamGeo model.""" |
| 772 | try: |
| 773 | self.progress_bar.setVisible(True) |
| 774 | self.progress_bar.setRange(0, 0) # Indeterminate |
| 775 | self.model_status.setText("Loading model...") |
| 776 | self.model_status.setStyleSheet("color: orange;") |
| 777 | QCoreApplication.processEvents() |
| 778 | |
| 779 | model_version = self.model_combo.currentText() |
| 780 | backend = self.backend_combo.currentText() |
| 781 | device = self.device_combo.currentText() |
| 782 | if device == "auto": |
| 783 | device = None |
| 784 | |
| 785 | confidence = self.conf_spin.value() |
| 786 | enable_interactive = self.interactive_check.isChecked() |
| 787 | |
| 788 | # Import and initialize the appropriate model |
| 789 | if "SamGeo3" in model_version: |
| 790 | from samgeo import SamGeo3 |
| 791 | |
| 792 | self.sam = SamGeo3( |
| 793 | backend=backend, |
| 794 | device=device, |
| 795 | confidence_threshold=confidence, |
| 796 | enable_inst_interactivity=enable_interactive, |
| 797 | ) |
| 798 | model_name = "SamGeo3" |
| 799 | elif "SamGeo2" in model_version: |
| 800 | from samgeo import SamGeo2 |
| 801 | |
| 802 | self.sam = SamGeo2( |
| 803 | device=device, |
| 804 | ) |
| 805 | model_name = "SamGeo2" |
| 806 | else: |
| 807 | from samgeo import SamGeo |
| 808 | |
| 809 | self.sam = SamGeo( |
| 810 | device=device, |
| 811 | ) |
| 812 | model_name = "SamGeo" |
| 813 | |
| 814 | self.model_status.setText(f"Model: {model_name} loaded") |
| 815 | self.model_status.setStyleSheet("color: green;") |
| 816 | self.log_message(f"{model_name} model loaded successfully") |
| 817 | |
| 818 | except Exception as e: |
| 819 | self.model_status.setText("Model: Failed to load") |
| 820 | self.model_status.setStyleSheet("color: red;") |
| 821 | self.show_error(f"Failed to load model: {str(e)}") |
| 822 | |
| 823 | finally: |
| 824 | self.progress_bar.setVisible(False) |
| 825 | |
| 826 | def set_image_from_layer(self): |
| 827 | """Set the image from the selected QGIS layer.""" |
nothing calls this directly
no test coverage detected