yuxinwenrick / tree-ring-watermark Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi, thanks for your work.
I am not able to understand, what changes should I make to watermark my pre generated images ? The code files seem to only run and test on some pre-defined datasets or create watermarked images using text prompts.
Any advice would be greatly appreciated.
Thanks
sorry to bother you ,sir
when i run python run_tree_ring_watermark.py --run_name no_attack --w_channel 3 --w_pattern ring --start 0 --end 1 --with_tracking --reference_model ViT-g-14 --reference_model_pretrain laion2b_s12b_b42k --w_seed=100
it go something wrong like
File "/root/autodl-tmp/tree-ring-watermark/run_tree_ring_watermark.py", line 218, in
main(args)
File "/root/autodl-tmp/tree-ring-watermark/run_tree_ring_watermark.py", line 66, in main
outputs_no_w = pipe(
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/root/autodl-tmp/tree-ring-watermark/modified_stable_diffusion.py", line 175, in call
noise_pred = self.unet(latent_model_input, t, encoder_hidden_states=text_embeddings).sample
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/diffusers/models/unet_2d_condition.py", line 424, in forward
sample, res_samples = downsample_block(
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/diffusers/models/unet_2d_blocks.py", line 777, in forward
hidden_states = attn(hidden_states, encoder_hidden_states=encoder_hidden_states).sample
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/diffusers/models/attention.py", line 216, in forward
hidden_states = block(hidden_states, encoder_hidden_states=encoder_hidden_states, timestep=timestep)
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/diffusers/models/attention.py", line 490, in forward
hidden_states = self.attn1(norm_hidden_states, attention_mask=attention_mask) + hidden_states
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/diffusers/models/attention.py", line 638, in forward
hidden_states = self._attention(query, key, value, attention_mask)
File "/root/miniconda3/envs/tree/lib/python3.10/site-packages/diffusers/models/attention.py", line 654, in _attention
attention_scores = torch.baddbmm(
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 320.00 MiB (GPU 0; 9.77 GiB total capacity; 7.96 GiB already allocated; 42.69 MiB free; 8.08 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
tree-ring-watermark/optim_utils.py
Line 3 in 8ff1711
tree-ring-watermark/optim_utils.py
Line 73 in 1e40351
type of g_noise
and np.array(img1)
is already np.uint8
, so np.clip
won't have any effect.
Hi author,
Thank you for your great work. I'm looking into your code, but I cannot find the one for computing p-value. Could you please provide that? Thank you!
Best,
Lijun
Hi,
Thank you for making the code public! I was trying to generate 128x128 images with TreeRing but I could only get noises. Adjusting the watermark radius doesn't help (see the following two examples, one with r = 10 and the other with r = 0).
In comparison, generating 512x512 images works well (the prompt is the same as 128x128 case).
I was wondering if there are something I'm missing. Below is my code snippet, which I slightly adapted from your code without modifying any core functionalities.
import argparse
import os
from diffusers import DPMSolverMultistepScheduler
from inverse_stable_diffusion import InversableStableDiffusionPipeline
import torch
from tqdm import tqdm
from tree_ring_utils import (get_watermarking_mask, get_watermarking_pattern,
inject_watermark, set_random_seed)
torch.set_grad_enabled(False)
ROOT = "/".join(os.path.dirname(os.path.abspath(__file__)).split("/")[:-1])
def main(args):
# load diffusion model
device = "cuda" if torch.cuda.is_available() else "cpu"
scheduler = DPMSolverMultistepScheduler.from_pretrained(
args.model_id, subfolder="scheduler"
)
pipe = InversableStableDiffusionPipeline.from_pretrained(
args.model_id,
scheduler=scheduler,
torch_dtype=torch.float16,
revision="fp16",
)
pipe = pipe.to(device)
# prompts
if not args.from_file:
prompt = args.prompt
assert prompt is not None
data = [prompt]
save_dir = (
f"{ROOT}/imgs/TreeRing/samples"
)
else:
print(f"reading prompts from {args.from_file}")
with open(args.from_file, "r") as f:
data = f.read().splitlines()
save_dir = (
f"{ROOT}/imgs/TreeRing/samples_{len(data)}/samples"
)
os.makedirs(save_dir, exist_ok=True)
# ground-truth patch
gt_patch = get_watermarking_pattern(pipe, args, device)
torch.save(
torch.view_as_real(gt_patch.cpu()),
f"{save_dir}/gt_patch.pt",
)
for i in tqdm(range(len(data))):
seed = i + args.gen_seed
current_prompt = data[i]
# generation with watermarking
set_random_seed(seed)
init_latents_w = pipe.get_random_latents(
height=args.image_length, width=args.image_length)
# get watermarking mask
watermarking_mask = get_watermarking_mask(init_latents_w, args, device)
# inject watermark
init_latents_w = inject_watermark(
init_latents_w, watermarking_mask, gt_patch, args
)
# https://huggingface.co/CompVis/stable-diffusion-v1-4/discussions/10#641051192a593afb553c969e
with torch.autocast("cuda"):
outputs_w = pipe(
current_prompt,
num_images_per_prompt=args.num_images,
guidance_scale=args.guidance_scale,
num_inference_steps=args.num_inference_steps,
height=args.image_length,
width=args.image_length,
latents=init_latents_w,
)
orig_image_w = outputs_w.images[0]
# output is PIL image
orig_image_w.save(os.path.join(save_dir, f"{i:06d}.png"))
# watermarking mask is needed in decoding
torch.save(
watermarking_mask.cpu(),
f"{save_dir}/watermarking_mask.pt",
)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="diffusion watermark")
parser.add_argument("--image_length", default=512, type=int)
parser.add_argument("--model_id", default="stabilityai/stable-diffusion-2-1-base")
parser.add_argument("--num_images", default=1, type=int)
parser.add_argument("--guidance_scale", default=7.5, type=float)
parser.add_argument("--num_inference_steps", default=50, type=int)
parser.add_argument("--gen_seed", default=0, type=int)
# watermark
parser.add_argument("--w_seed", default=999999, type=int)
parser.add_argument("--w_channel", default=3, type=int)
parser.add_argument("--w_pattern", default="ring")
parser.add_argument("--w_mask_shape", default="circle")
parser.add_argument("--w_radius", default=10, type=int)
parser.add_argument("--w_measurement", default="l1_complex")
parser.add_argument("--w_injection", default="complex")
parser.add_argument("--w_pattern_const", default=0, type=float)
# prompt
parser.add_argument(
"--prompt",
type=str,
nargs="?",
default="a professional photograph of an astronaut riding a triceratops",
help="the prompt to render",
)
parser.add_argument(
"--from-file",
type=str,
help="if specified, load prompts from this file, separated by newlines",
)
args = parser.parse_args()
main(args)
Would appreciate any help/inputs! Thanks!
Hi Yuxin,
Sorry for bothering your again. In run_tree_ring_watermark.py
, the reversed_latents_w
is obtained by
reversed_latents_w = pipe.forward_diffusion(
latents=image_latents_w,
text_embeddings=text_embeddings, # why provides the information about prompt?
guidance_scale=1,
num_inference_steps=args.test_num_inference_steps,
)
However, I notice you write "While it may not be surprising that inversion is accurate for unconditional diffusion models, inversion also succeeds well-enough for conditional diffusion models, even when the conditioning c is not provided. This property of inversion will be exploited heavily by our watermark below."
Does the conditioning c mean text_embeddings
?
Hi!Great Work!
I ran this work a few months ago,it worked well at that time.But when i ran this work today,i met a problem as follows:
`C:\Users\Asus\.conda\envs\tree\lib\site-packages\huggingface_hub\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
warnings.warn(
urllib3.exceptions.SSLError: TLS/SSL connection has been closed (EOF) (_ssl.c:1135)
The above exception was the direct cause of the following exception:
urllib3.exceptions.ProxyError: ('Unable to connect to proxy', SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1135)')))
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\requests\adapters.py", line 486, in send
resp = conn.urlopen(
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\urllib3\connectionpool.py", line 847, in urlopen
retries = retries.increment(
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\urllib3\util\retry.py", line 515, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /stabilityai/stable-diffusion-2-1-base/resolve/main/scheduler/scheduler_config.json (Caused by ProxyError('Unable to connect to proxy', SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1135)'))))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\diffusers\configuration_utils.py", line 326, in load_config
config_file = hf_hub_download(
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\huggingface_hub\file_download.py", line 1221, in hf_hub_download
return _hf_hub_download_to_cache_dir(
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\huggingface_hub\file_download.py", line 1282, in _hf_hub_download_to_cache_dir
(url_to_download, etag, commit_hash, expected_size, head_call_error) = _get_metadata_or_catch_error(
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\huggingface_hub\file_download.py", line 1722, in _get_metadata_or_catch_error
metadata = get_hf_file_metadata(url=url, proxies=proxies, timeout=etag_timeout, headers=headers)
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\huggingface_hub\file_download.py", line 1645, in get_hf_file_metadata
r = _request_wrapper(
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\huggingface_hub\file_download.py", line 372, in _request_wrapper
response = _request_wrapper(
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\huggingface_hub\file_download.py", line 395, in _request_wrapper
response = get_session().request(method=method, url=url, **params)
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\huggingface_hub\utils\_http.py", line 66, in send
return super().send(request, *args, **kwargs)
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\requests\adapters.py", line 513, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /stabilityai/stable-diffusion-2-1-base/resolve/main/scheduler/scheduler_config.json (Caused by ProxyError('Unable to connect to proxy', SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1135)'))))"), '(Request ID: 6af51b5b-214b-42b4-9dd8-6bbd92e52cef)')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "run_tree_ring_watermark.py", line 218, in <module>
main(args)
File "run_tree_ring_watermark.py", line 28, in main
scheduler = DPMSolverMultistepScheduler.from_pretrained(args.model_id, subfolder='scheduler')
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\diffusers\schedulers\scheduling_utils.py", line 118, in from_pretrained
config, kwargs = cls.load_config(
File "C:\Users\Asus\.conda\envs\tree\lib\site-packages\diffusers\configuration_utils.py", line 371, in load_config
raise EnvironmentError(
OSError: Can't load config for 'stabilityai/stable-diffusion-2-1-base'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'stabilityai/stable-diffusion-2-1-base' is the correct path to a directory containing a scheduler_config.json file`
Do you know how to solve this problem?Thanks!
Hey, I was trying to recreate the table one in your research paper: https://arxiv.org/pdf/2310.01867.pdf
I noticed that you have said to run : python run_tree_ring_watermark_imagenet_fid.py --run_name imgnet_fid_run --gt_data imagenet --model_id 256x256_diffusion --w_radius 10 --w_channel 2 --w_pattern ring --start 0 --end 10000 --with_tracking --reference_model dummy
in: https://github.com/YuxinWenRick/tree-ring-watermark/blob/main/scripts/tree_ring_imagenet.sh
but run_tree_ring_watermark_imagenet_fid.py file is not available.
Thank you,
In the experiments of attacking image rotation and image cropping, which criterion is used to evaluate whether a watermark is added in the experiments, the criteria of run_tree_ring_watermark.py or the criteria of p_values?
Good job. Thanks for your sharing. I have a code problem in my own computer.
super(InversableStableDiffusionPipeline, self).init(vae,
super(ModifiedStableDiffusionPipeline, self).init(vae,
AttributeError: 'bool' object has no attribute 'module'
However, I don't find any code using this one. Do you know how to solve this problem?
Thanks for this interesting work.
I didn't see the code for the DDIM experiments. Could you upload the code to this repo? Thank you very much.
Thank you very much for your contribution to the community. May I ask where can I get the "datasets" in the" optim_utils.py"file?
from datasets import load_dataset
Hi,
I cannot find a fixed threshold in your code. I find you create a threshold called 'thresholds' after generation watermarked images and images without watermark in 'run_tree_ring_watermark'.
Is this the threshold you mentioned in your paper? For example, when L1 distance is lower than threshold, the watermark is detected. After all image generation with and without watermark, the threshold is calculated using a good tradeoff between FPR and TPR.
Waiting for your kind reply and thanks for your good work.
Hi Yuxin,
Your work is really intersting and novel!
I want to further understand the detail of your method. However, I have trouble visualizing the watermark pattern. I notice
that gt_patch
is (1,4,64,64) and I can observe the ring in each channel, while I cannot find that in
that init_latents_w
, reversed_latents_no_w
and reversed_latents_w
.
Could you help me? Thanks!
if i want to know the image an watermark what i need to do
Hi, Sorry to bother you.
I am very interested in your project, but have some problems when I reproduce,
such as "RuntimeError: "roll_cuda" not implemented for 'ComplexHalf'" ,
I didn't find any useful way to solve it, can you help me?
Looking forward to your reply!
hi i'm sorry to bother you,when i reduce the code ,i got the problem can you tell me what i need to do?
Traceback (most recent call last):
File "D:\treering\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "D:\treering\lib\site-packages\urllib3\util\connection.py", line 95, in create_connection
raise err
File "D:\treering\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
sock.connect(sa)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\treering\lib\site-packages\urllib3\connectionpool.py", line 715, in urlopen
httplib_response = self._make_request(
File "D:\treering\lib\site-packages\urllib3\connectionpool.py", line 404, in _make_request
self._validate_conn(conn)
File "D:\treering\lib\site-packages\urllib3\connectionpool.py", line 1058, in _validate_conn
conn.connect()
File "D:\treering\lib\site-packages\urllib3\connection.py", line 363, in connect
self.sock = conn = self._new_conn()
File "D:\treering\lib\site-packages\urllib3\connection.py", line 179, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x000001FEBAB75CD0>, 'Connection to huggingface
.co timed out. (connect timeout=10)')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\treering\lib\site-packages\requests\adapters.py", line 486, in send
resp = conn.urlopen(
File "D:\treering\lib\site-packages\urllib3\connectionpool.py", line 799, in urlopen
retries = retries.increment(
File "D:\treering\lib\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /stabilityai/st
able-diffusion-2-1-base/resolve/main/scheduler/scheduler_config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnectio
n object at 0x000001FEBAB75CD0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\treering\lib\site-packages\huggingface_hub\file_download.py", line 1247, in hf_hub_download
metadata = get_hf_file_metadata(
File "D:\treering\lib\site-packages\huggingface_hub\utils_validators.py", line 118, in _inner_fn
return fn(*args, **kwargs)
File "D:\treering\lib\site-packages\huggingface_hub\file_download.py", line 1624, in get_hf_file_metadata
r = _request_wrapper(
File "D:\treering\lib\site-packages\huggingface_hub\file_download.py", line 402, in _request_wrapper
response = _request_wrapper(
File "D:\treering\lib\site-packages\huggingface_hub\file_download.py", line 425, in _request_wrapper
response = get_session().request(method=method, url=url, **params)
File "D:\treering\lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "D:\treering\lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "D:\treering\lib\site-packages\huggingface_hub\utils_http.py", line 63, in send
return super().send(request, *args, **kwargs)
File "D:\treering\lib\site-packages\requests\adapters.py", line 507, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with ur
l: /stabilityai/stable-diffusion-2-1-base/resolve/main/scheduler/scheduler_config.json (Caused by ConnectTimeoutError(<urllib3.connect
ion.HTTPSConnection object at 0x000001FEBAB75CD0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: 4
3779387-774b-4ccb-9524-86ab46d4ce5d)')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\treering\lib\site-packages\diffusers\configuration_utils.py", line 326, in load_config
config_file = hf_hub_download(
File "D:\treering\lib\site-packages\huggingface_hub\utils_validators.py", line 118, in _inner_fn
return fn(*args, **kwargs)
File "D:\treering\lib\site-packages\huggingface_hub\file_download.py", line 1377, in hf_hub_download
raise LocalEntryNotFoundError(
huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find
the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "run_tree_ring_watermark.py", line 218, in
main(args)
File "run_tree_ring_watermark.py", line 28, in main
scheduler = DPMSolverMultistepScheduler.from_pretrained(args.model_id, subfolder='scheduler')
File "D:\treering\lib\site-packages\diffusers\schedulers\scheduling_utils.py", line 118, in from_pretrained
config, kwargs = cls.load_config(
File "D:\treering\lib\site-packages\diffusers\configuration_utils.py", line 354, in load_config
raise EnvironmentError(
OSError: stabilityai/stable-diffusion-2-1-base does not appear to have a file named scheduler_config.json.
wandb: You can sync this run to the cloud by running:
wandb: wandb sync C:\Users\LENOVO\Desktop\code\tree-ring-watermark\wandb\offline-run-20231213_205324-orwb3fbr
wandb: Find logs at: .\wandb\offline-run-20231213_205324-orwb3fbr\logs
I use the following settings to run the code with others unchanged.
--w_channel 0
--w_mask_shape circle
--w_radius 32
--w_pattern_const 1
--w_pattern const/zero
But the accuracy is only 0% and 75% (where if a value is lower than 0 then it is assigned to 0, and if larger than 0 then it is assigned to 1).
Under "const" pattern, the value of reversed_latents_w_fft[0, 0, 32, 32]
is -250.2 but the target is 1. May I ask what is the reason for this?
Besides, I also add a pattern named "ring_bits" to assign a 0/1 bit to a ring randomly but acc is also 0.
sorry to bother you again,doctor . i run the script,However, when the program finishes running and I don't see the saved model file, am I missing something?
Hi, this is Xin. I am interested in your contribution to watermark, greak work!
when I run the "target_api.py"in src/tree_ring_watermark , several issue happend. So I upgrade my transformer, pytorch and diffuser to the latest version. But still I got this error below, could you please help me?
ValueError Traceback (most recent call last)
Cell In[1], line 30
27 pipe = pipe.to(device)
29 shape = (1, 4, 64, 64)
---> 30 latents, w_key, w_mask = get_noise(shape, pipe)
32 watermarked_image = pipe(prompt="an astronaut", latents=latents).images[0]
34 is_watermarked = detect(watermarked_image, pipe, w_key, w_mask)
File ~/water_mark/treering_wk/tree-ring-watermark/src/tree_ring_watermark/_get_noise.py:81, in get_noise(shape, model_hash, generator)
78 file_path = os.path.join(temp_dir, file_name)
79 np.save(file_path, w_key)
---> 81 org = get_org()
82 repo_id = os.path.join(org, model_hash)
84 api.create_repo(repo_id=repo_id, exist_ok=True, repo_type="dataset")
File ~/water_mark/treering_wk/tree-ring-watermark/src/tree_ring_watermark/utils.py:24, in get_org()
21 file_path = os.path.join(CACHE_PATH, FILE_PATH)
23 if not os.path.isfile(file_path):
---> 24 raise ValueError(f"{file_path} does not exist. Make sure to run trk.setup_repo(...)
first.")
25 with open(file_path, 'r') as file:
26 current_org = file.read()
ValueError: /home/xin/./cache/trk/current_org does not exist. Make sure to run trk.setup_repo(...)
first.
in this code: set_random_seed(seed)
init_latents_no_w = pipe.get_random_latents()
outputs_no_w = pipe(
.......
num_inference_steps=args.num_inference_steps,
.......
)
I modified num_inference_steps=args.num_inference_steps-1,Want to get x1...
After getting it, I want to get x0 through the latent of x1 through num_inference_steps=1, but I find that the image effect of x0 is worse than that of x1, is there no way to push it out at every step?
The only way to get x1 is init_latents_no_w = pipe.get_random_latents() and num_inference_steps=args.num_inference_steps-1.......
I hope you can help me or tell me about your pipe encapsulation, I would appreciate it
Dear author, I met a problem when testing the code. Could you please help me solve it? thank you very much!
Generating train split: 0%| | 0/54568 [00:00<?, ? examples/s]Failed to read file '/root/.cache/huggingface/datasets/downloads/870be28b4b7b1b74063e420fac9fb246f3159ab8b9a4a390c4f2b2e08e92eea9' with error <class 'datasets.table.CastError'>: Couldn't cast
Prompt: string
-- schema metadata --
pandas: '{"index_columns": [], "column_indexes": [], "columns": [{"name":' + 186
to
{'instruction': Value(dtype='string', id=None), 'output': Value(dtype='string', id=None), 'input': Value(dtype='string', id=None)}
because column names don't match
Generating train split: 0%| | 0/54568 [00:00<?, ? examples/s]
Traceback (most recent call last):
File "/root/miniconda3/lib/python3.8/site-packages/datasets/builder.py", line 1997, in _prepare_split_single
for _, table in generator:
File "/root/miniconda3/lib/python3.8/site-packages/datasets/packaged_modules/parquet/parquet.py", line 93, in generate_tables
yield f"{file_idx}{batch_idx}", self._cast_table(pa_table)
File "/root/miniconda3/lib/python3.8/site-packages/datasets/packaged_modules/parquet/parquet.py", line 71, in _cast_table
pa_table = table_cast(pa_table, self.info.features.arrow_schema)
File "/root/miniconda3/lib/python3.8/site-packages/datasets/table.py", line 2302, in table_cast
return cast_table_to_schema(table, schema)
File "/root/miniconda3/lib/python3.8/site-packages/datasets/table.py", line 2256, in cast_table_to_schema
raise CastError(
datasets.table.CastError: Couldn't cast
Prompt: string
-- schema metadata --
pandas: '{"index_columns": [], "column_indexes": [], "columns": [{"name":' + 186
to
{'instruction': Value(dtype='string', id=None), 'output': Value(dtype='string', id=None), 'input': Value(dtype='string', id=None)}
because column names don't match
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "run_tree_ring_watermark.py", line 217, in
main(args)
File "run_tree_ring_watermark.py", line 42, in main
dataset, prompt_key = get_dataset(args)
File "/root/tree-ring-watermark-main/optim_utils.py", line 109, in get_dataset
dataset = load_dataset(args.dataset)['test']
File "/root/miniconda3/lib/python3.8/site-packages/datasets/load.py", line 2616, in load_dataset
builder_instance.download_and_prepare(
File "/root/miniconda3/lib/python3.8/site-packages/datasets/builder.py", line 1029, in download_and_prepare
self._download_and_prepare(
File "/root/miniconda3/lib/python3.8/site-packages/datasets/builder.py", line 1124, in _download_and_prepare
self._prepare_split(split_generator, **prepare_split_kwargs)
File "/root/miniconda3/lib/python3.8/site-packages/datasets/builder.py", line 1884, in _prepare_split
for job_id, done, content in self._prepare_split_single(
File "/root/miniconda3/lib/python3.8/site-packages/datasets/builder.py", line 2040, in _prepare_split_single
raise DatasetGenerationError("An error occurred while generating the dataset") from e
datasets.exceptions.DatasetGenerationError: An error occurred while generating the dataset
Pipelines loaded with torch_dtype=torch.float16
cannot run with cpu
device. It is not recommended to move them to cpu
as running them will fail. Please make sure to use an accelerator to run the pipeline in inference, due to the lack of support forfloat16
operations on this device in PyTorch. Please, remove the torch_dtype=torch.float16
argument, or use another device for inference.
Pipelines loaded with torch_dtype=torch.float16
cannot run with cpu
device. It is not recommended to move them to cpu
as running them will fail. Please make sure to use an accelerator to run the pipeline in inference, due to the lack of support forfloat16
operations on this device in PyTorch. Please, remove the torch_dtype=torch.float16
argument, or use another device for inference.
Pipelines loaded with torch_dtype=torch.float16
cannot run with cpu
device. It is not recommended to move them to cpu
as running them will fail. Please make sure to use an accelerator to run the pipeline in inference, due to the lack of support forfloat16
operations on this device in PyTorch. Please, remove the torch_dtype=torch.float16
argument, or use another device for inference.
i got this problem,what i need to do
Traceback (most recent call last):
File "run_tree_ring_watermark.py", line 218, in
main(args)
File "run_tree_ring_watermark.py", line 131, in main
sims = measure_similarity([orig_image_no_w, orig_image_w], current_prompt, ref_model, ref_clip_preprocess, ref_tokenizer, device)
File "/home/aistudio/tree-ring-watermark/optim_utils.py", line 88, in measure_similarity
image_features = model.encode_image(img_batch)
File "/home/aistudio/tree-ring-watermark/open_clip/model.py", line 213, in encode_image
features = self.visual(image)
File "/home/aistudio/work/*conda3/envs/tree/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/aistudio/tree-ring-watermark/open_clip/transformer.py", line 482, in forward
x = self.ln_pre(x)
File "/home/aistudio/work/*conda3/envs/tree/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/home/aistudio/tree-ring-watermark/open_clip/transformer.py", line 28, in forward
x = F.layer_norm(x, self.normalized_shape, self.weight, self.bias, self.eps)
File "/home/aistudio/work/*conda3/envs/tree/lib/python3.8/site-packages/torch/nn/functional.py", line 2487, in layer_norm
return torch.layer_norm(input, normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled)
RuntimeError: expected scalar type Half but found Float
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.