Update requirements.txt
Browse files- requirements.txt +5 -42
requirements.txt
CHANGED
|
@@ -1,42 +1,5 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
import cv2
|
| 7 |
-
|
| 8 |
-
# Initialize the Flask app
|
| 9 |
-
myapp = Flask(__name__)
|
| 10 |
-
CORS(myapp) # Enable CORS if needed
|
| 11 |
-
|
| 12 |
-
@myapp.route('/')
|
| 13 |
-
def home():
|
| 14 |
-
return "Welcome to the Image Denoiser!" # Basic home response
|
| 15 |
-
|
| 16 |
-
@myapp.route('/denoise', methods=['POST'])
|
| 17 |
-
def denoise_image():
|
| 18 |
-
if 'image' not in request.files:
|
| 19 |
-
return jsonify({"error": "No image provided"}), 400
|
| 20 |
-
|
| 21 |
-
input_image = request.files['image'].read() # Read the uploaded image
|
| 22 |
-
img = Image.open(io.BytesIO(input_image))
|
| 23 |
-
|
| 24 |
-
# Convert to OpenCV format
|
| 25 |
-
img_cv = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
|
| 26 |
-
|
| 27 |
-
# Apply fastNlMeansDenoising
|
| 28 |
-
denoised_img = cv2.fastNlMeansDenoising(img_cv, None, h=10, templateWindowSize=7, searchWindowSize=21)
|
| 29 |
-
|
| 30 |
-
# Convert back to PIL format
|
| 31 |
-
denoised_img_pil = Image.fromarray(cv2.cvtColor(denoised_img, cv2.COLOR_BGR2RGB))
|
| 32 |
-
|
| 33 |
-
# Save to bytes
|
| 34 |
-
img_byte_arr = io.BytesIO()
|
| 35 |
-
denoised_img_pil.save(img_byte_arr, format='PNG')
|
| 36 |
-
img_byte_arr.seek(0)
|
| 37 |
-
|
| 38 |
-
return send_file(img_byte_arr, mimetype='image/png')
|
| 39 |
-
|
| 40 |
-
# Add this block to make sure your app runs when called
|
| 41 |
-
if __name__ == "__main__":
|
| 42 |
-
myapp.run(host='0.0.0.0', port=7860) # Run directly if needed for testing
|
|
|
|
| 1 |
+
Flask
|
| 2 |
+
Flask-Cors
|
| 3 |
+
pillow
|
| 4 |
+
opencv-python
|
| 5 |
+
gunicorn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|