Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | 
         @@ -1,40 +1,32 @@ 
     | 
|
| 1 | 
         
             
            import streamlit as st
         
     | 
| 2 | 
         
            -
            from  
     | 
| 3 | 
         | 
| 4 | 
         
            -
            # Load the  
     | 
| 5 | 
         
            -
             
     | 
| 6 | 
         
            -
            def load_diffusion_pipeline():
         
     | 
| 7 | 
         
            -
                try:
         
     | 
| 8 | 
         
            -
                    pipeline = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-3-medium")
         
     | 
| 9 | 
         
            -
                    return pipeline
         
     | 
| 10 | 
         
            -
                except Exception as e:
         
     | 
| 11 | 
         
            -
                    st.error(f"Error loading model: {e}")
         
     | 
| 12 | 
         | 
| 13 | 
         
            -
            def  
     | 
| 14 | 
         
            -
                 
     | 
| 15 | 
         
            -
             
     | 
| 16 | 
         
            -
             
     | 
| 17 | 
         
            -
                except Exception as e:
         
     | 
| 18 | 
         
            -
                    st.error(f"Error generating response: {e}")
         
     | 
| 19 | 
         | 
| 20 | 
         
             
            def main():
         
     | 
| 21 | 
         
            -
                st.title('Hugging Face  
     | 
| 22 | 
         | 
| 23 | 
         
            -
                #  
     | 
| 24 | 
         
            -
                 
     | 
| 
         | 
|
| 25 | 
         | 
| 26 | 
         
            -
                #  
     | 
| 27 | 
         
            -
                 
     | 
| 
         | 
|
| 28 | 
         | 
| 29 | 
         
            -
             
     | 
| 30 | 
         
            -
             
     | 
| 31 | 
         
            -
             
     | 
| 32 | 
         
            -
             
     | 
| 33 | 
         
            -
                             
     | 
| 34 | 
         
            -
                        st.success(' 
     | 
| 35 | 
         
            -
                        st. 
     | 
| 36 | 
         
            -
                    else:
         
     | 
| 37 | 
         
            -
                        st.warning('Please enter a prompt.')
         
     | 
| 38 | 
         | 
| 39 | 
         
             
            if __name__ == '__main__':
         
     | 
| 40 | 
         
             
                main()
         
     | 
| 
         | 
|
| 1 | 
         
             
            import streamlit as st
         
     | 
| 2 | 
         
            +
            from transformers import pipeline
         
     | 
| 3 | 
         | 
| 4 | 
         
            +
            # Load the audio classification pipeline
         
     | 
| 5 | 
         
            +
            audio_classification_pipeline = pipeline("audio-classification", model="MIT/ast-finetuned-audioset-10-10-0.4593")
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 6 | 
         | 
| 7 | 
         
            +
            def classify_audio(audio_file):
         
     | 
| 8 | 
         
            +
                # Perform audio classification
         
     | 
| 9 | 
         
            +
                results = audio_classification_pipeline(audio=audio_file)
         
     | 
| 10 | 
         
            +
                return results
         
     | 
| 
         | 
|
| 
         | 
|
| 11 | 
         | 
| 12 | 
         
             
            def main():
         
     | 
| 13 | 
         
            +
                st.title('Hugging Face Audio Classification')
         
     | 
| 14 | 
         | 
| 15 | 
         
            +
                # File uploader for audio file
         
     | 
| 16 | 
         
            +
                st.subheader('Upload Audio File:')
         
     | 
| 17 | 
         
            +
                audio_file = st.file_uploader("Choose a WAV file", type=["wav"])
         
     | 
| 18 | 
         | 
| 19 | 
         
            +
                # Check if audio file is uploaded
         
     | 
| 20 | 
         
            +
                if audio_file is not None:
         
     | 
| 21 | 
         
            +
                    st.audio(audio_file, format='audio/wav')
         
     | 
| 22 | 
         | 
| 23 | 
         
            +
                    # Button to classify audio
         
     | 
| 24 | 
         
            +
                    if st.button('Classify'):
         
     | 
| 25 | 
         
            +
                        with st.spinner('Classifying...'):
         
     | 
| 26 | 
         
            +
                            # Perform classification
         
     | 
| 27 | 
         
            +
                            results = classify_audio(audio_file)
         
     | 
| 28 | 
         
            +
                        st.success('Classification complete!')
         
     | 
| 29 | 
         
            +
                        st.write("Prediction:", results)
         
     | 
| 
         | 
|
| 
         | 
|
| 30 | 
         | 
| 31 | 
         
             
            if __name__ == '__main__':
         
     | 
| 32 | 
         
             
                main()
         
     |