Zw07 commited on
Commit
05a9ed9
·
verified ·
1 Parent(s): 7237be7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -29
app.py CHANGED
@@ -1,23 +1,30 @@
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
- from PIL import Image
 
 
 
 
 
4
 
5
- pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
6
 
7
- st.title("Hot Dog? Or Not?")
8
 
9
- file_name = st.file_uploader("Upload a hot dog candidate image")
10
 
11
- if file_name is not None:
12
- col1, col2 = st.columns(2)
13
 
14
- image = Image.open(file_name)
15
- col1.image(image, use_column_width=True)
16
- predictions = pipeline(image)
17
 
18
- col2.header("Probabilities")
19
- for p in predictions:
20
- col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
21
 
22
  # Main web app
23
  def main():
@@ -50,23 +57,23 @@ def main():
50
 
51
  action = st.selectbox("Select Action", ["Add Watermark", "Decode Watermark"])
52
 
53
- if action == "Add Watermark":
54
- watermark_text = st.text_input("The watermark (0, 1 list of length-16):", value=st.session_state.def_value)
55
- add_watermark_button = st.button("Add Watermark", key="add_watermark_btn")
56
- if add_watermark_button: # 点击按钮后执行的
57
- if audio_file and watermark_text:
58
- with st.spinner("Adding Watermark..."):
59
- watermarked_audio, encode_time_cost = add_watermark(tmp_input_audio_file, watermark_text)
60
- st.write("Watermarked Audio:")
61
- print("watermarked_audio:", watermarked_audio)
62
- st.audio(watermarked_audio, format="audio/wav")
63
- st.write("Time Cost: %d seconds" % encode_time_cost)
64
-
65
- # st.button("Add Watermark", disabled=False)
66
- elif action == "Decode Watermark":
67
- if st.button("Decode"):
68
- with st.spinner("Decoding..."):
69
- decode_watermark(tmp_input_audio_file)
70
 
71
 
72
  if __name__ == "__main__":
 
1
+ import time
2
+ import
3
  import streamlit as st
4
  from transformers import pipeline
5
+ import os
6
+ import torch
7
+ import datetime
8
+ import numpy as np
9
+ import soundfile
10
+ from wavmark.utils import file_reader
11
 
12
+ # pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
13
 
14
+ # st.title("Hot Dog? Or Not?")
15
 
16
+ # file_name = st.file_uploader("Upload a hot dog candidate image")
17
 
18
+ # if file_name is not None:
19
+ # col1, col2 = st.columns(2)
20
 
21
+ # image = Image.open(file_name)
22
+ # col1.image(image, use_column_width=True)
23
+ # predictions = pipeline(image)
24
 
25
+ # col2.header("Probabilities")
26
+ # for p in predictions:
27
+ # col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
28
 
29
  # Main web app
30
  def main():
 
57
 
58
  action = st.selectbox("Select Action", ["Add Watermark", "Decode Watermark"])
59
 
60
+ # if action == "Add Watermark":
61
+ # watermark_text = st.text_input("The watermark (0, 1 list of length-16):", value=st.session_state.def_value)
62
+ # add_watermark_button = st.button("Add Watermark", key="add_watermark_btn")
63
+ # if add_watermark_button: # 点击按钮后执行的
64
+ # if audio_file and watermark_text:
65
+ # with st.spinner("Adding Watermark..."):
66
+ # watermarked_audio, encode_time_cost = add_watermark(tmp_input_audio_file, watermark_text)
67
+ # st.write("Watermarked Audio:")
68
+ # print("watermarked_audio:", watermarked_audio)
69
+ # st.audio(watermarked_audio, format="audio/wav")
70
+ # st.write("Time Cost: %d seconds" % encode_time_cost)
71
+
72
+ # # st.button("Add Watermark", disabled=False)
73
+ # elif action == "Decode Watermark":
74
+ # if st.button("Decode"):
75
+ # with st.spinner("Decoding..."):
76
+ # decode_watermark(tmp_input_audio_file)
77
 
78
 
79
  if __name__ == "__main__":