Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	
		Siyun He
		
	commited on
		
		
					Commit 
							
							·
						
						668c3c8
	
1
								Parent(s):
							
							4713b6b
								
update
Browse files
    	
        .DS_Store
    ADDED
    
    | Binary file (6.15 kB). View file | 
|  | 
    	
        app.py
    CHANGED
    
    | @@ -65,25 +65,6 @@ def process_frame(frame): | |
| 65 |  | 
| 66 | 
             
                return frame
         | 
| 67 |  | 
| 68 | 
            -
            # # Display the frame
         | 
| 69 | 
            -
            # def display_frame():
         | 
| 70 | 
            -
            #     cap = cv2.VideoCapture(0)
         | 
| 71 | 
            -
            #     while True:
         | 
| 72 | 
            -
            #         ret, frame = cap.read()
         | 
| 73 | 
            -
            #         if not ret:
         | 
| 74 | 
            -
            #             break
         | 
| 75 | 
            -
             | 
| 76 | 
            -
            #         frame = process_frame(frame)
         | 
| 77 | 
            -
            #         cv2.imshow('SnapLens', frame)
         | 
| 78 | 
            -
             | 
| 79 | 
            -
            #         k = cv2.waitKey(10)
         | 
| 80 | 
            -
            #         if k == ord('q'):
         | 
| 81 | 
            -
            #             break
         | 
| 82 | 
            -
             | 
| 83 | 
            -
            #     cap.release()
         | 
| 84 | 
            -
            #     cv2.destroyAllWindows()
         | 
| 85 | 
            -
             | 
| 86 | 
            -
            # display_frame()
         | 
| 87 |  | 
| 88 | 
             
            # Gradio webcam input
         | 
| 89 | 
             
            def webcam_input(frame):
         | 
| @@ -95,6 +76,8 @@ with gr.Blocks() as demo: | |
| 95 | 
             
                with gr.Row():
         | 
| 96 | 
             
                    with gr.Column():
         | 
| 97 | 
             
                        input_img = gr.Image(label="Input", sources="webcam", streaming=True)
         | 
|  | |
| 98 | 
             
                input_img.stream(webcam_input, [input_img], [input_img], stream_every=0.1, concurrency_limit=30)
         | 
|  | |
| 99 | 
             
            if __name__ == "__main__":
         | 
| 100 | 
             
                demo.launch(share=True)
         | 
|  | |
| 65 |  | 
| 66 | 
             
                return frame
         | 
| 67 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 68 |  | 
| 69 | 
             
            # Gradio webcam input
         | 
| 70 | 
             
            def webcam_input(frame):
         | 
|  | |
| 76 | 
             
                with gr.Row():
         | 
| 77 | 
             
                    with gr.Column():
         | 
| 78 | 
             
                        input_img = gr.Image(label="Input", sources="webcam", streaming=True)
         | 
| 79 | 
            +
                        next_button = gr.Button("Next Glasses")
         | 
| 80 | 
             
                input_img.stream(webcam_input, [input_img], [input_img], stream_every=0.1, concurrency_limit=30)
         | 
| 81 | 
            +
                next_button.click(change_glasses)
         | 
| 82 | 
             
            if __name__ == "__main__":
         | 
| 83 | 
             
                demo.launch(share=True)
         |