Skip to content

Commit

Permalink
Update BdnfCorpusCreator.py
Browse files Browse the repository at this point in the history
Soucis de compatibilité résolu.
Il y avait un soucis avec la fonction cluster.

Pour ceux qui ont planté BDNF avec le script d'avant:
Veuillez accepter mes humbles excuses mais le bogue est très simple à réparer:

J'ai donné la solution pour déboguer BDNF (en cas de gel et si il refuse de s'ouvrir) sur la présentation de mon projet.

Là, tout marche parfaitement !
  • Loading branch information
Giribot authored Jan 10, 2025
1 parent 3f0e293 commit f643b2a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions BdnfCorpusCreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def create_bdnf_zip(input_dir, output_zip, thumbnail_size=(256, 256), max_image_
"""
thumbnails_dir = "Thumbnails"
highres_dir = "Highres"
clusters = []

with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:
# Parcourir les images dans le répertoire source
Expand Down Expand Up @@ -67,11 +68,15 @@ def create_bdnf_zip(input_dir, output_zip, thumbnail_size=(256, 256), max_image_
thumbnail_path = os.path.join(thumbnails_dir, file)
zipf.write(temp_thumb_path, thumbnail_path)
os.remove(temp_thumb_path)

# Ajouter les informations au fichier XML
clusters.append(f"<Cluster><Name>{file}</Name><Path>{highres_path}</Path></Cluster>")
except Exception as e:
print(f"Erreur lors du traitement de l'image {file}: {e}")

# Ajouter un fichier Cluster.xml vide par défaut (ou personnalisé)
cluster_content = """<Cluster><Description>BDNF Corpus</Description></Cluster>"""
# Ajouter un fichier Cluster.xml avec une structure compatible
cluster_content = """<Clusters>
{}</Clusters>""".format("\n".join(clusters))
zipf.writestr("Cluster.xml", cluster_content)

print(f"Fichier ZIP créé : {output_zip}")
Expand Down

0 comments on commit f643b2a

Please sign in to comment.