Project-AgML / AgML

AgML is a centralized framework for agricultural machine learning. AgML provides access to public agricultural datasets for common agricultural deep learning tasks, with standard benchmarks and pretrained models, as well the ability to generate synthetic data and annotations.
Apache License 2.0
176 stars 28 forks source link

FileNotFoundError: "... /style_tomato_sample.xml" #29

Closed ctyeong closed 1 year ago

ctyeong commented 2 years ago

I was following your "AgML-Synthetic.ipynb" example.

I have run the code below:

generator.generate(name = 'tomato_sample', num_images = 3),

and an error follows:

FileNotFoundError                         Traceback (most recent call last)
/tmp/ipykernel_2880/388478152.py in <module>
      1 # Generate the data.
----> 2 generator.generate(name = 'tomato_sample', num_images = 3)

~/anaconda3/envs/agml/lib/python3.7/site-packages/agml/synthetic/generator.py in generate(self, name, num_images, output_dir, convert_data)
    355         xml_options = self._convert_options_to_xml()
    356         xml_file_base = f"style_{name}.xml"
--> 357         xml_options.write(os.path.join(XML_PATH, xml_file_base))
    358         xml_options.write(os.path.join(metadata_dir, xml_file_base))
    359 

~/anaconda3/envs/agml/lib/python3.7/xml/etree/ElementTree.py in write(self, file_or_filename, encoding, xml_declaration, default_namespace, method, short_empty_elements)
    758                 encoding = "us-ascii"
    759         enc_lower = encoding.lower()
--> 760         with _get_writer(file_or_filename, enc_lower) as write:
    761             if method == "xml" and (xml_declaration or
    762                     (xml_declaration is None and

~/anaconda3/envs/agml/lib/python3.7/contextlib.py in __enter__(self)
    110         del self.args, self.kwds, self.func
    111         try:
--> 112             return next(self.gen)
    113         except StopIteration:
    114             raise RuntimeError("generator didn't yield") from None

~/anaconda3/envs/agml/lib/python3.7/xml/etree/ElementTree.py in _get_writer(file_or_filename, encoding)
    795         else:
    796             file = open(file_or_filename, "w", encoding=encoding,
--> 797                         errors="xmlcharrefreplace")
    798         with file:
    799             yield file.write

FileNotFoundError: [Errno 2] No such file or directory: '/home/username/anaconda3/envs/agml/lib/python3.7/site-packages/agml/_helios/Helios/projects/SyntheticImageAnnotation/xml/style_tomato_sample.xml'
amogh7joshi commented 1 year ago

Can you show me the output of the following command?

  1. tree /home/username/anaconda3/envs/agml/lib/python3.7/site-packages/agml/_helios/Helios/projects/SyntheticImageAnnotation (assuming username is your home directory, otherwise replace with the corresponding path).
amogh7joshi commented 1 year ago

I can't reproduce your error on my end, so there may be a path issue, or Helios may not have been fully installed. Try deleting the Helios directly and re-installing/compiling it.

ctyeong commented 1 year ago

Can you show me the output of the following command?

  1. tree /home/username/anaconda3/envs/agml/lib/python3.7/site-packages/agml/_helios/Helios/projects/SyntheticImageAnnotation (assuming username is your home directory, otherwise replace with the corresponding path).

I can only find .gitignore under /home/username/anaconda3/envs/agml/lib/python3.7/site-packages/agml/_helios/Helios/projects. No SyntheticImageAnnotation.

amogh7joshi commented 1 year ago

Try deleting the Helios directory directly and re-installing/compiling it.

ctyeong commented 1 year ago

Okay. I think .../agml/_helios/Helios seems to be same as shown here: https://github.com/PlantSimulationLab/Helios, where the projects folder only contains .gitignore.

Try deleting the Helios directory directly and re-installing/compiling it.

Could you give me a more clarification on what to compile from this directory?

amogh7joshi commented 1 year ago

Delete the Helios directory in agml/_helios, then run agml.synthetic.reinstall_helios().

ctyeong commented 1 year ago

That worked! Actually, agml.synthetic.reinstall_helios() shows an error when there is no agml/_helios. So, I removed and re-installed the whole agml using pip to run agml.synthetic.reinstall_helios() afterwards. Then, generator.generate(name = 'tomato_sample', num_images = 3) went without issue. Thanks!