mohamed12ahmed commited on
Commit
e57dcb6
·
verified ·
1 Parent(s): f817bf6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -27,7 +27,8 @@ def get_model():
27
  global model
28
  if model is None:
29
  try:
30
- model = torch.jit.load("real_denoising", map_location=device)
 
31
  model.to(device)
32
  model.eval()
33
  print("✅ Model loaded successfully")
@@ -42,7 +43,8 @@ def process_image_with_model(input_path):
42
  if model is None:
43
  raise RuntimeError("Model not loaded.")
44
 
45
- task = "Deraining"
 
46
  out_dir = os.path.join(app.config["RESULTS_FOLDER"], task)
47
  os.makedirs(out_dir, exist_ok=True)
48
 
@@ -72,7 +74,7 @@ html_content = """
72
  <!DOCTYPE html>
73
  <html>
74
  <head>
75
- <title>Restormer Deraining Demo</title>
76
  <style>
77
  body { text-align:center; font-family: sans-serif; }
78
  .container { max-width: 600px; margin: auto; padding: 20px; border: 1px solid #ccc; border-radius: 8px; }
@@ -83,7 +85,7 @@ html_content = """
83
  </head>
84
  <body>
85
  <div class="container">
86
- <h1>Restormer: Deraining Demo</h1>
87
  <form id="uploadForm" enctype="multipart/form-data">
88
  <input type="file" id="fileInput" name="file" accept="image/*" required><br><br>
89
  <button type="submit">Process Image</button>
@@ -124,7 +126,6 @@ html_content = """
124
  loading.style.display = "block";
125
 
126
  try {
127
- // Corrected the fetch URL to match the Flask route
128
  const response = await fetch("/process_image", {
129
  method: "POST",
130
  body: formData
 
27
  global model
28
  if model is None:
29
  try:
30
+ # تم تعديل اسم النموذج هنا ليحتوي على .pt
31
+ model = torch.jit.load("real_denoising.pt", map_location=device)
32
  model.to(device)
33
  model.eval()
34
  print("✅ Model loaded successfully")
 
43
  if model is None:
44
  raise RuntimeError("Model not loaded.")
45
 
46
+ # تم تعديل اسم المهمة هنا
47
+ task = "Real_Denoising"
48
  out_dir = os.path.join(app.config["RESULTS_FOLDER"], task)
49
  os.makedirs(out_dir, exist_ok=True)
50
 
 
74
  <!DOCTYPE html>
75
  <html>
76
  <head>
77
+ <title>Restormer Denoise Demo</title>
78
  <style>
79
  body { text-align:center; font-family: sans-serif; }
80
  .container { max-width: 600px; margin: auto; padding: 20px; border: 1px solid #ccc; border-radius: 8px; }
 
85
  </head>
86
  <body>
87
  <div class="container">
88
+ <h1>Restormer: Denoising Demo</h1>
89
  <form id="uploadForm" enctype="multipart/form-data">
90
  <input type="file" id="fileInput" name="file" accept="image/*" required><br><br>
91
  <button type="submit">Process Image</button>
 
126
  loading.style.display = "block";
127
 
128
  try {
 
129
  const response = await fetch("/process_image", {
130
  method: "POST",
131
  body: formData