omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    new file/project couldn't be created

    Pythonista
    3
    66
    19465
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cvp
      cvp last edited by cvp

      If he uses the mlmodel I found, it is here

      but I also used it without any problems, with images of short texts

      1 Reply Last reply Reply Quote 0
      • pavlinb
        pavlinb last edited by

        Yes, I used mentioned model.

        And with clean images with few symbols all is ok.

        Probably the problem occurs with complex images.

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @JonB last edited by

          @JonB said:

          Have you already pre-compiled the model?

          The omz code compiles the model before using it.

          1 Reply Last reply Reply Quote 0
          • cvp
            cvp last edited by cvp

            For each character, the compiled model is generated as
            file:///private/var/mobile/Containers/Data/Application/C285FD04-6489-45E5-A6C5-D4A44D300BBC/tmp/(A%20Document%20Being%20Saved%20By%20Pythonista3%20643)/OCR.mlmodelc/

            Omz code needs to be improved so this compilation is done only once, not for each character...

            1 Reply Last reply Reply Quote 0
            • JonB
              JonB last edited by

              It might be a good idea to compile it once, copy it to a regular location, then delete the tmp file. That's what Apple recommends

              If you run the code that does a fresh compile every time, you will quickly fill up the tmp storage. I'm not how reliable the cleaning of tmp files is.

              1 Reply Last reply Reply Quote 0
              • pavlinb
                pavlinb last edited by

                Agree. .

                1 Reply Last reply Reply Quote 0
                • cvp
                  cvp last edited by

                  Set vn_model global,
                  call load_model at begin of main and
                  remove load_model in _classify_image_data

                  Script is quicker and does not generate a compiled model at each character

                  1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp last edited by

                    After run, tmp folder is empty

                    1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp last edited by

                      def load_model():
                      	global vn_model
                      	
                      def _classify_img_data(img_data):
                      	global vn_model
                      	'''The main image classification method, used by `classify_image` (for camera images) and `classify_asset` (for photo library assets).'''
                      	#vn_model = load_model()
                      	
                      def main():
                          global vn_model
                          vn_model = load_model()
                      
                      1 Reply Last reply Reply Quote 0
                      • cvp
                        cvp last edited by

                        After some tests with small texts, Pythonista storage has increased of 1GB but I hope this will decrease in some hours...

                        1 Reply Last reply Reply Quote 0
                        • cvp
                          cvp last edited by

                          import os
                          d = '/private/var/mobile/Containers/Data/Application/C285FD04-6489-45E5-A6C5-D4A44D300BBC/tmp/'
                          os.chdir(d)
                          l = os.listdir()
                          for e in l:
                          	print(e)
                          

                          Shows ....a lot of

                          (A Document Being Saved By Pythonista3 92)
                          (A Document Being Saved By Pythonista3 315)
                          (A Document Being Saved By Pythonista3 262)
                          (A Document Being Saved By Pythonista3 628)
                          (A Document Being Saved By Pythonista3 563)
                          (A Document Being Saved By Pythonista3 54)
                          
                          1 Reply Last reply Reply Quote 0
                          • cvp
                            cvp last edited by

                            Trying to remove it gives

                            PermissionError: [Errno 1] Operation not permitted: '(A Document Being Saved By Pythonista3 92)'
                            
                            1 Reply Last reply Reply Quote 0
                            • cvp
                              cvp last edited by

                              Each file has a size of 96 bytes??????????

                              1 Reply Last reply Reply Quote 0
                              • pavlinb
                                pavlinb last edited by

                                Works.

                                No more crashes with complex images.

                                1 Reply Last reply Reply Quote 0
                                • cvp
                                  cvp last edited by cvp

                                  Shame on me, each line is a folder, that's why it is 96 bytes and unremovable 😢 because not empty

                                  1 Reply Last reply Reply Quote 0
                                  • cvp
                                    cvp last edited by cvp

                                    The .mlmodelc are not permitted for removal...

                                    1 Reply Last reply Reply Quote 0
                                    • cvp
                                      cvp last edited by

                                      .mlmodelc is still a folder, one more time, shame on me...
                                      1GB of temp files...

                                      1 Reply Last reply Reply Quote 0
                                      • cvp
                                        cvp last edited by cvp

                                        In the text detection script, add

                                        	print(c_model_url)
                                        

                                        Note the code d = '/private/var/mobile/Containers/Data/Application/C285FD04-6489-45E5-A6C5-D4A44D300BBC/tmp/'
                                        Replace it in the little script here-under to clean /tmp folder

                                        import os
                                        
                                        n = 0
                                        s = 0
                                        def loc_dirs(path):
                                        		global n,s
                                        		try:
                                        			file_path = path
                                        			os.chdir(file_path)
                                        			filelist = os.listdir(file_path)
                                        			for file in filelist:
                                        				print(file)				
                                        				f_full = file_path + file
                                        				if os.path.isdir(f_full):
                                        					loc_dirs(path+file+'/') # explore it
                                        				else:	
                                        
                                        					loc_size = os.path.getsize(f_full)
                                        					n = n + 1
                                        					s = s + loc_size
                                        					os.remove(f_full)
                                        			os.rmdir(file_path)
                                        		except Exception as e:
                                        			print('exception: ',e)
                                        		return
                                        
                                        
                                        d = '/private/var/mobile/Containers/Data/Application/C285FD04-6489-45E5-A6C5-D4A44D300BBC/tmp/'
                                        #loc_dirs(d)
                                        print(n,s)
                                        
                                        1 Reply Last reply Reply Quote 0
                                        • pavlinb
                                          pavlinb last edited by

                                          print(n,s)

                                          3637 2027261814

                                          cvp 1 Reply Last reply Reply Quote 0
                                          • cvp
                                            cvp @pavlinb last edited by

                                            @pavlinb 20GB?

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors