alexkueck commited on
Commit
95c1779
1 Parent(s): a96e074

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -357,6 +357,10 @@ def create_picture(history, prompt):
357
  # using the Image module from PIL library to view the image
358
  #Image.open(response.raw)
359
 
 
 
 
 
360
 
361
  def invoke (prompt, file, history, rag_option, model_option, openai_api_key, k=3, top_p=0.6, temperature=0.5, max_new_tokens=4048, max_context_length_tokens=2048, repetition_penalty=1.3,):
362
  global splittet
@@ -439,13 +443,8 @@ def invoke (prompt, file, history, rag_option, model_option, openai_api_key, k=3
439
  if (prompt.find('zeichnen') != -1):
440
  #Bild ausgeben
441
  image = Image.open(io.BytesIO(result))
442
- #buffer = io.BytesIO()
443
- #image.save(buffer, format='PNG')
444
- #desiredObject = buffer.getbuffer()
445
- b = io.BytesIO()
446
- image.save(b, format='PNG')
447
 
448
- history[-1][1] = "<img src='data:image/png;base64,{0}'/>".format(b64encode(b.getvalue()).decode('utf-8')) #file.name,
449
  print("history zeichnen......................")
450
  print(history)
451
  if shared_state.interrupted:
 
357
  # using the Image module from PIL library to view the image
358
  #Image.open(response.raw)
359
 
360
+ def umwandeln_fuer_anzeige(image):
361
+ buffer = io.BytesIO()
362
+ image.save(buffer, format='PNG')
363
+ return buffer.getvalue()
364
 
365
  def invoke (prompt, file, history, rag_option, model_option, openai_api_key, k=3, top_p=0.6, temperature=0.5, max_new_tokens=4048, max_context_length_tokens=2048, repetition_penalty=1.3,):
366
  global splittet
 
443
  if (prompt.find('zeichnen') != -1):
444
  #Bild ausgeben
445
  image = Image.open(io.BytesIO(result))
 
 
 
 
 
446
 
447
+ history[-1][1] = "<img src='data:image/png;base64,{0}'/>".format(b64encode(umwandeln_fuer_anzeige(image)).decode('utf-8'))
448
  print("history zeichnen......................")
449
  print(history)
450
  if shared_state.interrupted: