mshumer / gpt-author

MIT License
2.45k stars 354 forks source link

FileNotFoundError: [Errno 2] No such file or directory: '/content/cover.png' #7

Closed StrumykTomira closed 1 year ago

StrumykTomira commented 1 year ago

This is my first use of Jupyter :) I'm using Jupyter locally, on my Windows.

I've received such error:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[14], line 13
     10     chapter_titles[i] = {chapter_number_and_title: chapter}
     12 # Create the cover
---> 13 create_cover_image(str(chapter_titles))
     15 # Create the EPUB file
     16 create_epub(title, 'AI', chapter_titles, '/content/cover.png')

Cell In[2], line 51, in create_cover_image(plot)
     48 data = response.json()
     50 for i, image in enumerate(data["artifacts"]):
---> 51     with open(f"/content/cover.png", "wb") as f: # replace this if running locally, to where you store the cover file
     52         f.write(base64.b64decode(image["base64"]))

File ~\Documents\Python\p3_10\lib\site-packages\IPython\core\interactiveshell.py:284, in _modified_open(file, *args, **kwargs)
    277 if file in {0, 1, 2}:
    278     raise ValueError(
    279         f"IPython won't let you open fd={file} by default "
    280         "as it is likely to crash IPython. If you know what you are doing, "
    281         "you can use builtins' open."
    282     )
--> 284 return io_open(file, *args, **kwargs)

FileNotFoundError: [Errno 2] No such file or directory: '/content/cover.png'

Of course - i've put my Stability Key in stability_api_key variable, and make a "content" directory before run (in the same directory as the script AND one level higher). There are no pictures In my Stability history also (and i can manually create pictures there).

snip3r009 commented 1 year ago

look here: https://github.com/mshumer/gpt-author/issues/3

MartinAbilev commented 1 year ago

I just change it to c:/content/cover.png I not using stability just put some random image there

StrumykTomira commented 1 year ago

look here: #3

This is similar, but not the same issue. There is no picture created on my Stability account (and then no file in directory). But i'll check it with other path.

MartinAbilev commented 1 year ago

ya can try for local env

import os

absolute_path = os.path.dirname(__file__)
relative_path = "content/cover.png"
full_path = os.path.join(absolute_path, relative_path)
StrumykTomira commented 1 year ago

Thank You @MartinAbilev I'm trying now with 'content/cover.png' because 'prompts/write_chapter...' is working OK.

Writing chapter 3... Output for prompt "write_chapter_1770" has been written to prompts/write_chapter_1770.txt

I have also reduced the costs of this tests from 0.25 USD to 0.02 USD :D

StrumykTomira commented 1 year ago

IT WORKS!!1111oneone :D Thank You @snip3r009 and @MartinAbilev

StrumykTomira commented 1 year ago

Now i can optimise prompts and the rest of the code for better books. I'm closing this thread.