d22cs051 commited on
Commit
dea4a98
1 Parent(s): 1cdf4f4

adding dir via dockerfile

Browse files
Files changed (2) hide show
  1. Dockerfile +3 -2
  2. app.py +6 -3
Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
- FROM python:3.8.1-slim-buster
2
 
3
  RUN apt-get update
4
- RUN apt-get install build-essential -y
5
 
6
  # create a new user
7
  # RUN useradd -m -u 1000 user
@@ -41,4 +41,5 @@ RUN pip install protobuf==3.20.* --no-cache-dir
41
  # COPY --chown=user . $HOME/code
42
  # RUN ls -la $HOME/code
43
  # RUN chown -r 777:777 /code
 
44
  CMD ["python3", "app.py"]
 
1
+ FROM python:3.8.1-slim
2
 
3
  RUN apt-get update
4
+ RUN apt-get install ffmpeg build-essential -y
5
 
6
  # create a new user
7
  # RUN useradd -m -u 1000 user
 
41
  # COPY --chown=user . $HOME/code
42
  # RUN ls -la $HOME/code
43
  # RUN chown -r 777:777 /code
44
+ RUN mkdir flagged
45
  CMD ["python3", "app.py"]
app.py CHANGED
@@ -33,15 +33,18 @@ class DFSeparationApp:
33
 
34
  def predict(self, audio_file):
35
  # Load the audio file
36
- audio_tensor = torch.tensor(audio_file[0]).to(self.device)
 
 
37
  with torch.no_grad():
38
  # Make prediction
39
  output = self.model(audio_tensor)
40
- preds = output.argmax(dim=-1)
41
  probs = output.softmax(dim=-1)
 
42
  print(f"[LOG] Prediction: {preds.item()}")
43
  print(f"[LOG] Probability: {probs.max().item()}")
44
- return preds.item(), probs.max().item()
 
45
 
46
  def run(self):
47
  print(f"[LOG] Running the app...")
 
33
 
34
  def predict(self, audio_file):
35
  # Load the audio file
36
+ print(f"[LOG] Audio file: {audio_file}")
37
+ audio_tensor = torch.tensor(audio_file[1],dtype=torch.float).unsqueeze(0)
38
+ print(f"[LOG] Audio tensor shape: {audio_tensor.shape}")
39
  with torch.no_grad():
40
  # Make prediction
41
  output = self.model(audio_tensor)
 
42
  probs = output.softmax(dim=-1)
43
+ preds = probs.argmax(dim=-1)
44
  print(f"[LOG] Prediction: {preds.item()}")
45
  print(f"[LOG] Probability: {probs.max().item()}")
46
+ pred_str = "Fake" if preds.item() == 1 else "Real"
47
+ return pred_str, probs.max().item()
48
 
49
  def run(self):
50
  print(f"[LOG] Running the app...")