Files
novafarma/scripts/clean_plant.py

34 lines
853 B
Python

from rembg import remove
from PIL import Image
import os
# Paths to clean
paths = [
"assets/PHASE_PACKS/0_DEMO/crops/cannabis/growth_stages/cannabis_stage4_ready.png",
"assets/PHASE_PACKS/1_FAZA_1/crops/cannabis/growth_stages/cannabis_stage4_ready.png"
]
def clean_image(path):
if not os.path.exists(path):
print(f"⚠️ File not found: {path}")
return
print(f"🍀 Processing: {path}")
try:
input_img = Image.open(path)
# Remove background using rembg (Zajček metoda)
output_img = remove(input_img)
# Save over original
output_img.save(path)
print(f"✨ Cleaned and saved: {path}")
except Exception as e:
print(f"❌ Error processing {path}: {e}")
if __name__ == "__main__":
for p in paths:
clean_image(p)