akhaliq HF Staff commited on
Commit
05acf34
·
verified ·
1 Parent(s): d32397a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -16
app.py CHANGED
@@ -1,16 +1,3 @@
1
- Of course. I have applied the necessary fix to your code.
2
-
3
- The issue was in the `janus_chat_responder` function. It was returning the file path of the generated image as a plain string (e.g., `'./output/chat_image_0.png'`). For Gradio's `ChatInterface` to render an image, the function must return it in a specific format.
4
-
5
- **The Fix:**
6
-
7
- Instead of returning a string path, the function should return a Gradio component. Since your code can generate multiple images (`parallel_size`), the best component to use is `gr.Gallery`.
8
-
9
- I have modified the `return` statements in `janus_chat_responder` to wrap the list of generated image paths in a `gr.Gallery` component. This will correctly display all the generated images in the chat window.
10
-
11
- Here is the complete, corrected code:
12
-
13
- ```python
14
  import os
15
  import torch
16
  import numpy as np
@@ -306,6 +293,4 @@ if __name__ == "__main__":
306
  dummy_image = Image.new('RGB', (100, 100), color = 'red')
307
  dummy_image.save("./assets/example_image.jpg")
308
 
309
- demo.launch()
310
-
311
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import torch
3
  import numpy as np
 
293
  dummy_image = Image.new('RGB', (100, 100), color = 'red')
294
  dummy_image.save("./assets/example_image.jpg")
295
 
296
+ demo.launch()