Upload Qwen_Qwen3-VL-4B-Instruct_1.py with huggingface_hub
Browse files37 unmodified lines383940414243444546474849505152535437 unmodified lineswith open('Qwen_Qwen3-VL-4B-Instruct_1.txt', 'w', encoding='utf-8') as f:f.write('Everything was good in Qwen_Qwen3-VL-4B-Instruct_1.txt')except Exception as e:with open('Qwen_Qwen3-VL-4B-Instruct_1.txt', 'w', encoding='utf-8') as f:import tracebacktraceback.print_exc(file=f)import osfrom slack_sdk import WebClientclient = WebClient(token=os.environ['SLACK_TOKEN'])client.chat_postMessage(channel='#exp-slack-alerts',text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/Qwen_Qwen3-VL-4B-Instruct_1.txt|Qwen_Qwen3-VL-4B-Instruct_1.txt>',)finally:from huggingface_hub import upload_fileupload_file(37 unmodified lines3839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828337 unmodified lineswith open('Qwen_Qwen3-VL-4B-Instruct_1.txt', 'w', encoding='utf-8') as f:f.write('Everything was good in Qwen_Qwen3-VL-4B-Instruct_1.txt')except Exception as e:import osfrom slack_sdk import WebClientclient = WebClient(token=os.environ['SLACK_TOKEN'])client.chat_postMessage(channel='#exp-slack-alerts',text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/Qwen_Qwen3-VL-4B-Instruct_1.txt|Qwen_Qwen3-VL-4B-Instruct_1.txt>',)with open('Qwen_Qwen3-VL-4B-Instruct_1.txt', 'a', encoding='utf-8') as f:import tracebackf.write('```CODE:# Load model directlyfrom transformers import AutoProcessor, AutoModelForVision2Seqprocessor = AutoProcessor.from_pretrained("Qwen/Qwen3-VL-4B-Instruct")model = AutoModelForVision2Seq.from_pretrained("Qwen/Qwen3-VL-4B-Instruct")messages = [{"role": "user","content": [{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},{"type": "text", "text": "What animal is on the candy?"}]},]inputs = processor.apply_chat_template(messages,add_generation_prompt=True,tokenize=True,return_dict=True,return_tensors="pt",).to(model.device)outputs = model.generate(**inputs, max_new_tokens=40)print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))```ERROR:')traceback.print_exc(file=f)finally:from huggingface_hub import upload_fileupload_file(
Qwen_Qwen3-VL-4B-Instruct_1.py+38-9