Spaces:
				
			
			
	
			
			
					
		Running
		
			on 
			
			CPU Upgrade
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
			on 
			
			CPU Upgrade
	Commit 
							
							·
						
						c2548d1
	
1
								Parent(s):
							
							895d93f
								
Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -1,12 +1,11 @@ | |
| 1 | 
             
            import gradio as gr
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            import  | 
| 4 | 
            -
            from  | 
| 5 | 
            -
            from diffusers import StableDiffusionPipeline
         | 
| 6 | 
             
            from datasets import load_dataset
         | 
| 7 | 
             
            from PIL import Image  
         | 
| 8 | 
            -
            from io import BytesIO
         | 
| 9 | 
            -
            import base64
         | 
| 10 | 
             
            import re
         | 
| 11 | 
             
            import os
         | 
| 12 | 
             
            import requests
         | 
| @@ -59,9 +58,8 @@ def infer(prompt): | |
| 59 | 
             
                payload = {'prompt': prompt}
         | 
| 60 | 
             
                images_request = requests.post(url, json = payload)
         | 
| 61 | 
             
                for image in images_request.json()["images"]:
         | 
| 62 | 
            -
                     | 
| 63 | 
            -
                    images.append( | 
| 64 | 
            -
                
         | 
| 65 |  | 
| 66 | 
             
                return images, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
         | 
| 67 |  | 
| @@ -337,9 +335,8 @@ with block: | |
| 337 | 
             
                    ex.dataset.headers = [""]
         | 
| 338 |  | 
| 339 |  | 
| 340 | 
            -
                    text.submit(infer, inputs=text, outputs=[gallery, community_icon, loading_icon, share_button])
         | 
| 341 | 
            -
                    
         | 
| 342 | 
            -
                    btn.click(infer, inputs=text, outputs=[gallery, community_icon, loading_icon, share_button])
         | 
| 343 |  | 
| 344 | 
             
                    advanced_button.click(
         | 
| 345 | 
             
                        None,
         | 
|  | |
| 1 | 
             
            import gradio as gr
         | 
| 2 | 
            +
            #import torch
         | 
| 3 | 
            +
            #from torch import autocast
         | 
| 4 | 
            +
            #from diffusers import StableDiffusionPipeline
         | 
|  | |
| 5 | 
             
            from datasets import load_dataset
         | 
| 6 | 
             
            from PIL import Image  
         | 
| 7 | 
            +
            #from io import BytesIO
         | 
| 8 | 
            +
            #import base64
         | 
| 9 | 
             
            import re
         | 
| 10 | 
             
            import os
         | 
| 11 | 
             
            import requests
         | 
|  | |
| 58 | 
             
                payload = {'prompt': prompt}
         | 
| 59 | 
             
                images_request = requests.post(url, json = payload)
         | 
| 60 | 
             
                for image in images_request.json()["images"]:
         | 
| 61 | 
            +
                    image_b64 = (f"data:image/png;base64,{image}")
         | 
| 62 | 
            +
                    images.append(image_b64)
         | 
|  | |
| 63 |  | 
| 64 | 
             
                return images, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
         | 
| 65 |  | 
|  | |
| 335 | 
             
                    ex.dataset.headers = [""]
         | 
| 336 |  | 
| 337 |  | 
| 338 | 
            +
                    text.submit(infer, inputs=text, outputs=[gallery, community_icon, loading_icon, share_button], _postprocess=False)
         | 
| 339 | 
            +
                    btn.click(infer, inputs=text, outputs=[gallery, community_icon, loading_icon, share_button], _postprocess=False)
         | 
|  | |
| 340 |  | 
| 341 | 
             
                    advanced_button.click(
         | 
| 342 | 
             
                        None,
         | 

