全局變量
This commit is contained in:
		
							
								
								
									
										3
									
								
								pp.py
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								pp.py
									
									
									
									
									
								
							@@ -18,7 +18,7 @@ import paddle
 | 
				
			|||||||
from PIL import Image, ImageFile
 | 
					from PIL import Image, ImageFile
 | 
				
			||||||
from paddleocr import PaddleOCR
 | 
					from paddleocr import PaddleOCR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
paddle.set_flags({'FLAGS_fraction_of_gpu_memory_to_use': 0.6}) # 限制显存占用为GPU的80%
 | 
					paddle.set_flags({'FLAGS_fraction_of_gpu_memory_to_use': 0.4}) # 限制显存占用为GPU的80%
 | 
				
			||||||
logging.disable(logging.DEBUG)    # 关闭DEBUG日志的打印
 | 
					logging.disable(logging.DEBUG)    # 关闭DEBUG日志的打印
 | 
				
			||||||
logging.disable(logging.WARNING)  # 关闭WARNING日志的打印
 | 
					logging.disable(logging.WARNING)  # 关闭WARNING日志的打印
 | 
				
			||||||
warnings.filterwarnings("ignore")
 | 
					warnings.filterwarnings("ignore")
 | 
				
			||||||
@@ -94,6 +94,7 @@ def process_ocr(model, image):
 | 
				
			|||||||
    return result
 | 
					    return result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def process_images(conn, offset=0) -> int:
 | 
					def process_images(conn, offset=0) -> int:
 | 
				
			||||||
 | 
					    global EN, CH, JP, KR, RU
 | 
				
			||||||
    with conn.cursor(pymysql.cursors.SSCursor) as cursor:
 | 
					    with conn.cursor(pymysql.cursors.SSCursor) as cursor:
 | 
				
			||||||
        cursor.execute("SELECT id, content FROM web_images WHERE text='' AND article_category_top_id=22 LIMIT 100 OFFSET %s", (offset,))
 | 
					        cursor.execute("SELECT id, content FROM web_images WHERE text='' AND article_category_top_id=22 LIMIT 100 OFFSET %s", (offset,))
 | 
				
			||||||
        for id, content in cursor.fetchall():
 | 
					        for id, content in cursor.fetchall():
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user