Spaces:
Runtime error
Runtime error
Commit ·
56eafc1
1
Parent(s): ed66e23
Update main.py
Browse files26 unmodified lines27282930313233343516 unmodified lines5253545556575859606162636465666768697071727374757677787980818226 unmodified linestop_p: float = 0.95repetition_penalty: float = 1.0def format_prompt(message, history):prompt = "<s>"#with open('Manuale.txt', 'r') as file:# manual_content = file.read()# prompt += f"Leggi questo manuale dopo ti farò delle domande: {manual_content}"16 unmodified lineshistory = [] # Puoi definire la history se necessariogenerated_response = generate(input_text, history, temperature, max_new_tokens, top_p, repetition_penalty)return {"response": generated_response}@app.get("/Immagine")def generate_image():client = Client("https://openskyml-fast-sdxl-stable-diffusion-xl.hf.space/--replicas/545b5tw7n/")result = client.predict("a giant monster with yellow face hybrid of dragon and spider, in dark dense foggy forest ","",25,5,1024,1024,453666937,fn_index=0)image_url = resultwith open(image_url, 'rb') as img_file:img_binary = img_file.read()img_base64 = base64.b64encode(img_binary).decode('utf-8')return {"response": img_base64}@app.get("/Test")def generate_image():result = "a giant monster hybrid of dragon and spider, in dark dense foggy forest "return {"response": result}@app.get("/")def read_general():26 unmodified lines27282930313233343536373839404116 unmodified lines585960616263646566676869707172737475767778798081828326 unmodified linestop_p: float = 0.95repetition_penalty: float = 1.0class InputImage(BaseModel):input: strnegativePrompt: str = ''steps: int = 25cfg: int = 5seed: int = 453666937def format_prompt(message, history):prompt = "<s>"#with open('Manuale.txt', 'r') as file:# manual_content = file.read()# prompt += f"Leggi questo manuale dopo ti farò delle domande: {manual_content}"16 unmodified lineshistory = [] # Puoi definire la history se necessariogenerated_response = generate(input_text, history, temperature, max_new_tokens, top_p, repetition_penalty)return generated_response@app.post("/Immagine")def generate_image(request: Request, input_data: InputImage):client = Client("https://openskyml-fast-sdxl-stable-diffusion-xl.hf.space/--replicas/545b5tw7n/")result = client.predict(input_data.input,input_data.negativePrompt,input_data.steps,input_data.cfg,1024,1024,input_data.seed,fn_index=0)image_url = resultwith open(image_url, 'rb') as img_file:img_binary = img_file.read()img_base64 = base64.b64encode(img_binary).decode('utf-8')return img_base64@app.get("/")def read_general():
main.py+16-15