Forum

Author Topic: Generate Masks Mode AI not working from Python  (Read 2458 times)

benton

  • Newbie
  • *
  • Posts: 31
    • View Profile
Generate Masks Mode AI not working from Python
« on: April 26, 2026, 10:09:17 PM »
agisoft 2.2.2
Win111

When i run this

      
         
         chunk.generateMasks(
            masking_mode=Metashape.MaskingModeAI,
            tolerance=10
            )   


I get this error

GenerateMasks: masking_mode = MaskingModeAI
Traceback (most recent call last):
  File "D:\SfM\Scripts\turntable_new.py", line 153, in <module>
    exec(f.read())
  File "<string>", line 148, in <module>
OSError: Can't open file: The system cannot find the file specified (2): {filename}_mask.png


Could someone give some insight why this fails?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15691
    • View Profile
Re: Generate Masks Mode AI not working from Python
« Reply #1 on: April 27, 2026, 05:38:44 PM »
Hello benton,

For AI masking method you need to use "path" argument to specify the full path to JSON file related to AI model. On Windows the default location is the following:
"C:/Users/<username>/AppData/Local/Agisoft/Metashape Pro/ai/default/U2Net_v1.json"
Best regards,
Alexey Pasumansky,
Agisoft LLC