Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Upload app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -18,18 +18,17 @@ def predict(img): | |
| 18 | 
             
                img_array = preprocess_input(img_array)  # เตรียมรูปภาพให้สอดคล้องกับความต้องการของโมเดล
         | 
| 19 |  | 
| 20 | 
             
                predictions = model.predict(img_array)
         | 
| 21 | 
            -
                 | 
| 22 | 
            -
                 | 
| 23 | 
            -
                confidence = predictions[0][class_idx]
         | 
| 24 |  | 
| 25 | 
            -
                return  | 
| 26 |  | 
| 27 | 
             
            # สร้าง Gradio Interface
         | 
| 28 | 
             
            interface = gr.Interface(
         | 
| 29 | 
             
                fn=predict,
         | 
| 30 | 
             
                inputs=gr.Image(type="pil", label="Upload an Image"),
         | 
| 31 | 
             
                outputs=gr.Label(num_top_classes=2, label="Predicted Class"),
         | 
| 32 | 
            -
                title=" | 
| 33 | 
             
                description="Upload an image to classify it into one of the classes."
         | 
| 34 | 
             
            )
         | 
| 35 |  | 
|  | |
| 18 | 
             
                img_array = preprocess_input(img_array)  # เตรียมรูปภาพให้สอดคล้องกับความต้องการของโมเดล
         | 
| 19 |  | 
| 20 | 
             
                predictions = model.predict(img_array)
         | 
| 21 | 
            +
                predictions = predictions[0]  # เอาค่าผลลัพธ์ของ batch เดียว
         | 
| 22 | 
            +
                confidence_dict = {class_names[i]: float(predictions[i]) for i in range(len(class_names))}
         | 
|  | |
| 23 |  | 
| 24 | 
            +
                return confidence_dict
         | 
| 25 |  | 
| 26 | 
             
            # สร้าง Gradio Interface
         | 
| 27 | 
             
            interface = gr.Interface(
         | 
| 28 | 
             
                fn=predict,
         | 
| 29 | 
             
                inputs=gr.Image(type="pil", label="Upload an Image"),
         | 
| 30 | 
             
                outputs=gr.Label(num_top_classes=2, label="Predicted Class"),
         | 
| 31 | 
            +
                title="Melanoma Classification with InceptionV3",
         | 
| 32 | 
             
                description="Upload an image to classify it into one of the classes."
         | 
| 33 | 
             
            )
         | 
| 34 |  |