I have come across a very strange issue, I am using miniconda
to test out the GPT-NEO
ai text generator, I would call it like this in the command prompt:
C:\tools\miniconda3\python C:\Users\Graham\Desktop\Files\programming\Languages\Python\gpt_neo_app\ai.py
Python Code:
from os import system
from transformers import pipeline
import json
try:
# generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B', device=-1)
generator = pipeline('text-generation', model='EleutherAI/gpt-neo-1.3B', device=-1)
outjson = generator("unlock your hip flexors", do_sample=True, max_length=500, temperature=1.9)
outtext = json.loads(json.dumps(outjson[0]))["generated_text"]
# with open(r"C:\Users\Graham\Desktop\Files\programming\Languages\Python\gpttext.txt", "w") as f:
with open("gpttext.txt", "w") as f:
f.write(outtext)
print(outtext)
except Exception:
pass
The part that fails is writing to the .txt file, no matter what i do (even commenting out the text generation code and just putting in a random string to be written) the .txt file is never created or written to.
The text generator is working fine, i even tried the full path to the .txt file this still never worked, such a basic issue i cannot seem to see the problem, is there anything i have missed or have done wrong? it seems fairly straight forward enough but it just will not be created.
Any help would be appreciated.